diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..8ea34be9 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim AS stainless + +RUN apt-get update && apt-get install -y \ + nodejs \ + npm \ + yarnpkg \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +# Yarn +RUN ln -sf /usr/bin/yarnpkg /usr/bin/yarn + +WORKDIR /workspace + +COPY package.json yarn.lock /workspace/ + +RUN yarn install + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..d55fc4d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..60f0e7a3 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint', 'unused-imports', 'prettier'], + rules: { + 'no-unused-vars': 'off', + 'prettier/prettier': 'error', + 'unused-imports/no-unused-imports': 'error', + }, + root: true, +}; diff --git a/.fern/metadata.json b/.fern/metadata.json deleted file mode 100644 index ef3f5299..00000000 --- a/.fern/metadata.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "cliVersion": "3.0.2", - "generatorName": "fernapi/fern-typescript-sdk", - "generatorVersion": "3.35.8", - "generatorConfig": { - "namespaceExport": "Intercom", - "allowCustomFetcher": true, - "skipResponseValidation": true, - "includeApiReference": true, - "noSerdeLayer": true, - "enableInlineTypes": true, - "inlinePathParameters": true, - "timeoutInSeconds": 20, - "packageJson": { - "license": "Apache-2.0", - "description": "Official Node bindings to the Intercom API", - "homepage": "https://github.com/intercom/intercom-node", - "bugs": "https://github.com/intercom/intercom-node/issues", - "keywords": ["intercom", "api"] - } - } -} diff --git a/.fernignore b/.fernignore deleted file mode 100644 index 4c7324f1..00000000 --- a/.fernignore +++ /dev/null @@ -1,8 +0,0 @@ -# Specify files that shouldn't be modified by Fern -.github/ISSUE_TEMPLATE.md -.github/PULL_REQUEST_TEMPLATE.md -.gitattributes -LICENSE -REPO_OWNER -tests/integration -.github/workflows/ci.yml \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 176a458f..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index bb13692e..00000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,20 +0,0 @@ -Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed. - -For feature requests please contact us at team@intercom.io - -## Version info - -- intercom-node version: -- Node version: - -## Expected behavior - -## Actual behavior - -## Steps to reproduce - -1. -2. -3. - -## Logs diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 34874cdf..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ -#### Why? - -Why are you making this change? - -#### How? - -Technical details on your change diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 268fb922..5301319b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,76 +1,47 @@ -name: ci - -on: [push] +name: CI +on: + push: + branches: + - v3 + pull_request: + branches: + - v3 + - next jobs: - compile: + lint: + name: lint runs-on: ubuntu-latest + steps: - - name: Checkout repo - uses: actions/checkout@v6 - - - name: Set up node - uses: actions/setup-node@v6 + - uses: actions/checkout@v4 - - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Compile - run: pnpm build + run: yarn install + - name: Check types + run: ./scripts/lint test: + name: test runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v6 - - - name: Set up node - uses: actions/setup-node@v6 - - - name: Install pnpm - uses: pnpm/action-setup@v4 + - uses: actions/checkout@v4 - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '18' - - name: Test - run: pnpm test - env: - INTERCOM_API_KEY: ${{ secrets.INTERCOM_API_KEY }} - API_TOKEN: ${{ secrets.INTERCOM_API_KEY }} + - name: Bootstrap + run: ./scripts/bootstrap - publish: - needs: [ compile, test ] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - name: Checkout repo - uses: actions/checkout@v6 - - name: Set up node - uses: actions/setup-node@v6 - - name: Install pnpm - uses: pnpm/action-setup@v4 - - name: Install dependencies - run: pnpm install - - name: Build - run: pnpm build + - name: Run tests + run: ./scripts/test - - name: Publish to npm - run: | - publish() { - npx -y npm@latest publish "$@" - } - if [[ ${GITHUB_REF} == *alpha* ]]; then - publish --access public --tag alpha - elif [[ ${GITHUB_REF} == *beta* ]]; then - publish --access public --tag beta - else - publish --access public - fi \ No newline at end of file diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 00000000..3e4972a8 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,32 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to NPM in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/intercom/intercom-node/actions/workflows/publish-npm.yml +name: Publish NPM +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: | + yarn install + + - name: Publish to NPM + run: | + bash ./bin/publish-npm + env: + NPM_TOKEN: ${{ secrets.INTERCOM_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..d54a416e --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,21 @@ +name: Release Doctor +on: + pull_request: + branches: + - v3 + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'intercom/intercom-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + NPM_TOKEN: ${{ secrets.INTERCOM_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 72271e04..3eed6ddf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +.prism.log node_modules -.DS_Store -/dist \ No newline at end of file +yarn-error.log +codegen.log +Brewfile.lock.json +dist +/deno +/*.tgz +.idea/ + diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..3548c5af --- /dev/null +++ b/.prettierignore @@ -0,0 +1,7 @@ +CHANGELOG.md +/ecosystem-tests/*/** +/node_modules +/deno + +# don't format tsc output, will break source maps +/dist diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..af75adaf --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "experimentalTernaries": true, + "printWidth": 110, + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..ce5b081b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "6.0.0-beta.3" +} diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..d3cca5f0 --- /dev/null +++ b/.stats.yml @@ -0,0 +1,2 @@ +configured_endpoints: 108 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a52cc0e4313a38d4329e6c2f40afa341d800389762fc643b9bf5b13248f8c5da.yml diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000..e4feee60 --- /dev/null +++ b/Brewfile @@ -0,0 +1 @@ +brew "node" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe5bc2f7..3985ddb3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,133 +1,107 @@ -# Contributing +## Setting up the environment -Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project. +This repository uses [`yarn@v1`](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable). +Other package managers may work but are not officially supported for development. -## Getting Started - -### Prerequisites - -- Node.js 20 or higher -- pnpm package manager - -### Installation - -Install the project dependencies: +To set up the repository, run: ```bash -pnpm install +yarn +yarn build ``` -### Building +This will install all the required dependencies and build output files to `dist/`. -Build the project: +## Modifying/Adding code -```bash -pnpm build -``` +Most of the SDK is generated code, and any modified code will be overridden on the next generation. The +`src/lib/` and `examples/` directories are exceptions and will never be overridden. -### Testing +## Adding and running examples -Run the test suite: +All files in the `examples/` directory are not modified by the Stainless generator and can be freely edited or +added to. ```bash -pnpm test -``` +// add an example to examples/.ts -Run specific test types: -- `pnpm test:unit` - Run unit tests -- `pnpm test:wire` - Run wire/integration tests +#!/usr/bin/env -S npm run tsn -T +… +``` -### Linting and Formatting +``` +chmod +x examples/.ts +# run the example against your api +yarn tsn -T examples/.ts +``` -Check code style: +## Using the repository from source -```bash -pnpm run lint -pnpm run format:check -``` +If you’d like to use the repository from source, you can either install from git or link to a cloned repository: -Fix code style issues: +To install via git: ```bash -pnpm run lint:fix -pnpm run format:fix +npm install git+ssh://git@github.com:intercom/intercom-node.git ``` -Or use the combined check command: +Alternatively, to link a local copy of the repo: ```bash -pnpm run check:fix +# Clone +git clone https://www.github.com/intercom/intercom-node +cd intercom-node + +# With yarn +yarn link +cd ../my-package +yarn link intercom-client + +# With pnpm +pnpm link --global +cd ../my-package +pnpm link -—global intercom-client ``` -## About Generated Code - -**Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated. - -### Generated Files - -The following directories contain generated code: -- `src/api/` - API client classes and types -- `src/serialization/` - Serialization/deserialization logic -- Most TypeScript files in `src/` - -### How to Customize +## Running tests -If you need to customize the SDK, you have two options: +Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. -#### Option 1: Use `.fernignore` - -For custom code that should persist across SDK regenerations: - -1. Create a `.fernignore` file in the project root -2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax) -3. Add your custom code to those files - -Files listed in `.fernignore` will not be overwritten when the SDK is regenerated. - -For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code). - -#### Option 2: Contribute to the Generator - -If you want to change how code is generated for all users of this SDK: - -1. The TypeScript SDK generator lives in the [Fern repository](https://github.com/fern-api/fern) -2. Generator code is located at `generators/typescript/sdk/` -3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md) -4. Submit a pull request with your changes to the generator +```bash +npx prism mock path/to/your/openapi.yml +``` -This approach is best for: -- Bug fixes in generated code -- New features that would benefit all users -- Improvements to code generation patterns +```bash +yarn run test +``` -## Making Changes +## Linting and formatting -### Workflow +This repository uses [prettier](https://www.npmjs.com/package/prettier) and +[eslint](https://www.npmjs.com/package/eslint) to format the code in the repository. -1. Create a new branch for your changes -2. Make your modifications -3. Run tests to ensure nothing breaks: `pnpm test` -4. Run linting and formatting: `pnpm run check:fix` -5. Build the project: `pnpm build` -6. Commit your changes with a clear commit message -7. Push your branch and create a pull request +To lint: -### Commit Messages +```bash +yarn lint +``` -Write clear, descriptive commit messages that explain what changed and why. +To format and fix all lint issues automatically: -### Code Style +```bash +yarn fix +``` -This project uses automated code formatting and linting. Run `pnpm run check:fix` before committing to ensure your code meets the project's style guidelines. +## Publishing and releases -## Questions or Issues? +Changes made to this repository via the automated release PR pipeline should publish to npm automatically. If +the changes aren't made through the automated pipeline, you may want to make releases manually. -If you have questions or run into issues: +### Publish with a GitHub workflow -1. Check the [Fern documentation](https://buildwithfern.com) -2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues) -3. Open a new issue if your question hasn't been addressed +You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/intercom/intercom-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. -## License +### Publish manually -By contributing to this project, you agree that your contributions will be licensed under the same license as the project. +If you need to manually release a package, you can run the `bin/publish-npm` script with an `NPM_TOKEN` set on +the environment. diff --git a/LICENSE b/LICENSE index 8d34fb6e..9d62253c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,201 @@ -Copyright 2015 Bob Long + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - http://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2024 Intercom + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 753ab107..94e180c1 100644 --- a/README.md +++ b/README.md @@ -1,270 +1,286 @@ -# Intercom TypeScript Library +# Intercom Node API Library -[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-node) -[![npm shield](https://img.shields.io/npm/v/intercom-client)](https://www.npmjs.com/package/intercom-client) +[![NPM version](https://img.shields.io/npm/v/intercom-client.svg)](https://npmjs.org/package/intercom-client) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/intercom-client) -The Intercom TypeScript library provides convenient access to the Intercom APIs from TypeScript. +This library provides convenient access to the Intercom REST API from server-side TypeScript or JavaScript. -## Project Updates +The REST API documentation can be found on [developers.intercom.com](https://developers.intercom.com). The full API of this library can be found in [api.md](api.md). -The TypeScript SDK has been updated to support latest API version (2.11). +It is generated with [Stainless](https://www.stainlessapi.com/). ## Installation ```sh -npm i -s intercom-client +npm install intercom-client ``` -## Reference - -A full reference for this library is available [here](https://github.com/intercom/intercom-node/blob/HEAD/./reference.md). - ## Usage -Instantiate and use the client with the following: +The full API of this library can be found in [api.md](api.md). -```typescript -import { IntercomClient } from "intercom-client"; + +```js +import Intercom from 'intercom-client'; -const client = new IntercomClient({ token: "YOUR_TOKEN" }); -await client.aiContent.createContentImportSource({ - url: "https://www.example.com" +const client = new Intercom({ + accessToken: process.env['INTERCOM_ACCESS_TOKEN'], // This is the default and can be omitted + environment: 'eu', // or 'us' | 'au'; defaults to 'us' }); + +async function main() { + const adminWithApp = await client.me.retrieve(); + + console.log(adminWithApp.id); +} + +main(); ``` -## Request And Response Types +### Request & Response types -The SDK exports all request and response types as TypeScript interfaces. Simply import them with the -following namespace: +This library includes TypeScript definitions for all request params and response fields. You may import and use them like so: -```typescript -import { Intercom } from "intercom-client"; + +```ts +import Intercom from 'intercom-client'; -const request: Intercom.ConfigureAwayAdminRequest = { - ... -}; +const client = new Intercom({ + accessToken: process.env['INTERCOM_ACCESS_TOKEN'], // This is the default and can be omitted + environment: 'eu', // or 'us' | 'au'; defaults to 'us' +}); + +async function main() { + const adminWithApp: Intercom.AdminWithApp | null = await client.me.retrieve(); +} + +main(); ``` -## Exception Handling +Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors. -When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error -will be thrown. +## Handling errors -```typescript -import { IntercomError } from "intercom-client"; +When the library is unable to connect to the API, +or if the API returns a non-success status code (i.e., 4xx or 5xx response), +a subclass of `APIError` will be thrown: -try { - await client.aiContent.createContentImportSource(...); -} catch (err) { - if (err instanceof IntercomError) { - console.log(err.statusCode); - console.log(err.message); - console.log(err.body); - console.log(err.rawResponse); + +```ts +async function main() { + const adminWithApp = await client.me.retrieve().catch(async (err) => { + if (err instanceof Intercom.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; } + }); } + +main(); ``` -## Pagination +Error codes are as followed: -List endpoints are paginated. The SDK provides an iterator so that you can simply loop over the items: +| Status Code | Error Type | +| ----------- | -------------------------- | +| 400 | `BadRequestError` | +| 401 | `AuthenticationError` | +| 403 | `PermissionDeniedError` | +| 404 | `NotFoundError` | +| 422 | `UnprocessableEntityError` | +| 429 | `RateLimitError` | +| >=500 | `InternalServerError` | +| N/A | `APIConnectionError` | -```typescript -import { IntercomClient } from "intercom-client"; +### Retries -const client = new IntercomClient({ token: "YOUR_TOKEN" }); -const pageableResponse = await client.articles.list(); -for await (const item of pageableResponse) { - console.log(item); -} +Certain errors will be automatically retried 2 times by default, with a short exponential backoff. +Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, +429 Rate Limit, and >=500 Internal errors will all be retried by default. -// Or you can manually iterate page-by-page -let page = await client.articles.list(); -while (page.hasNextPage()) { - page = page.getNextPage(); -} +You can use the `maxRetries` option to configure or disable this: -// You can also access the underlying response -const response = page.response; + +```js +// Configure the default for all requests: +const client = new Intercom({ + maxRetries: 0, // default is 2 +}); + +// Or, configure per-request: +await client.me.retrieve({ + maxRetries: 5, +}); ``` -## Advanced +### Timeouts -### Additional Headers +Requests time out after 1 minute by default. You can configure this with a `timeout` option: -If you would like to send additional headers as part of the request, use the `headers` request option. + +```ts +// Configure the default for all requests: +const client = new Intercom({ + timeout: 20 * 1000, // 20 seconds (default is 1 minute) +}); -```typescript -const response = await client.aiContent.createContentImportSource(..., { - headers: { - 'X-Custom-Header': 'custom value' - } +// Override per-request: +await client.me.retrieve({ + timeout: 5 * 1000, }); ``` -### Additional Query String Parameters +On timeout, an `APIConnectionTimeoutError` is thrown. -If you would like to send additional query string parameters as part of the request, use the `queryParams` request option. +Note that requests which time out will be [retried twice by default](#retries). -```typescript -const response = await client.aiContent.createContentImportSource(..., { - queryParams: { - 'customQueryParamKey': 'custom query param value' - } -}); -``` +## Advanced Usage -### Retries +### Accessing raw Response data (e.g., headers) -The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long -as the request is deemed retryable and the number of retry attempts has not grown larger than the configured -retry limit (default: 2). +The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return. -A request is deemed retryable when any of the following HTTP status codes is returned: +You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data. -- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) -- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) -- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) + +```ts +const client = new Intercom(); -Use the `maxRetries` request option to configure this behavior. +const response = await client.me.retrieve().asResponse(); +console.log(response.headers.get('X-My-Header')); +console.log(response.statusText); // access the underlying Response object -```typescript -const response = await client.aiContent.createContentImportSource(..., { - maxRetries: 0 // override maxRetries at the request level -}); +const { data: adminWithApp, response: raw } = await client.me.retrieve().withResponse(); +console.log(raw.headers.get('X-My-Header')); +console.log(adminWithApp.id); ``` -### Timeouts +### Making custom/undocumented requests + +This library is typed for convenient access to the documented API. If you need to access undocumented +endpoints, params, or response properties, the library can still be used. + +#### Undocumented endpoints -The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior. +To make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs. +Options on the client, such as retries, will be respected when making these requests. -```typescript -const response = await client.aiContent.createContentImportSource(..., { - timeoutInSeconds: 30 // override timeout to 30s +```ts +await client.post('/some/path', { + body: { some_prop: 'foo' }, + query: { some_query_arg: 'bar' }, }); ``` -### Aborting Requests +#### Undocumented request params -The SDK allows users to abort requests at any point by passing in an abort signal. +To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented +parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you +send will be sent as-is. -```typescript -const controller = new AbortController(); -const response = await client.aiContent.createContentImportSource(..., { - abortSignal: controller.signal +```ts +client.foo.create({ + foo: 'my_param', + bar: 12, + // @ts-expect-error baz is not yet public + baz: 'undocumented option', }); -controller.abort(); // aborts the request ``` -### Access Raw Response Data +For requests with the `GET` verb, any extra params will be in the query, all other requests will send the +extra param in the body. -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. +If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request +options. -```typescript -const { data, rawResponse } = await client.aiContent.createContentImportSource(...).withRawResponse(); +#### Undocumented response properties -console.log(data); -console.log(rawResponse.headers['X-My-Header']); -``` +To access undocumented response properties, you may access the response object with `// @ts-expect-error` on +the response object, or cast the response object to the requisite type. Like the request params, we do not +validate or strip extra properties from the response from the API. -### Logging +### Customizing the fetch client -The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options. +By default, this library uses `node-fetch` in Node, and expects a global `fetch` function in other environments. -```typescript -import { IntercomClient, logging } from "intercom-client"; +If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment, +(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`), +add the following import before your first import `from "Intercom"`: -const client = new IntercomClient({ - ... - logging: { - level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info - logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger - silent: false, // defaults to true, set to false to enable logging - } -}); +```ts +// Tell TypeScript and the package to use the global web fetch instead of node-fetch. +// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed. +import 'intercom-client/shims/web'; +import Intercom from 'intercom-client'; ``` -The `logging` object can have the following properties: -- `level`: The log level to use. Defaults to `logging.LogLevel.Info`. -- `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`. -- `silent`: Whether to silence the logger. Defaults to `true`. -The `level` property can be one of the following values: -- `logging.LogLevel.Debug` -- `logging.LogLevel.Info` -- `logging.LogLevel.Warn` -- `logging.LogLevel.Error` +To do the inverse, add `import "intercom-client/shims/node"` (which does import polyfills). +This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/intercom/intercom-node/tree/v3/src/_shims#readme)). -To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface. +### Logging and middleware -
-Custom logger examples +You may also provide a custom `fetch` function when instantiating the client, +which can be used to inspect or alter the `Request` or `Response` before/after each request: -Here's an example using the popular `winston` logging library. ```ts -import winston from 'winston'; - -const winstonLogger = winston.createLogger({...}); - -const logger: logging.ILogger = { - debug: (msg, ...args) => winstonLogger.debug(msg, ...args), - info: (msg, ...args) => winstonLogger.info(msg, ...args), - warn: (msg, ...args) => winstonLogger.warn(msg, ...args), - error: (msg, ...args) => winstonLogger.error(msg, ...args), -}; +import { fetch } from 'undici'; // as one example +import Intercom from 'intercom-client'; + +const client = new Intercom({ + fetch: async (url: RequestInfo, init?: RequestInit): Promise => { + console.log('About to make a request', url, init); + const response = await fetch(url, init); + console.log('Got response', response); + return response; + }, +}); ``` -Here's an example using the popular `pino` logging library. +Note that if given a `DEBUG=true` environment variable, this library will log all requests and responses automatically. +This is intended for debugging purposes only and may change in the future without notice. -```ts -import pino from 'pino'; - -const pinoLogger = pino({...}); +### Configuring an HTTP(S) Agent (e.g., for proxies) -const logger: logging.ILogger = { - debug: (msg, ...args) => pinoLogger.debug(args, msg), - info: (msg, ...args) => pinoLogger.info(args, msg), - warn: (msg, ...args) => pinoLogger.warn(args, msg), - error: (msg, ...args) => pinoLogger.error(args, msg), -}; -``` -
+By default, this library uses a stable agent for all http/https requests to reuse TCP connections, eliminating many TCP & TLS handshakes and shaving around 100ms off most requests. +If you would like to disable or customize this behavior, for example to use the API behind a proxy, you can pass an `httpAgent` which is used for all requests (be they http or https), for example: -### Runtime Compatibility + +```ts +import http from 'http'; +import { HttpsProxyAgent } from 'https-proxy-agent'; +// Configure the default for all requests: +const client = new Intercom({ + httpAgent: new HttpsProxyAgent(process.env.PROXY_URL), +}); -The SDK works in the following runtimes: +// Override per-request: +await client.me.retrieve({ + httpAgent: new http.Agent({ keepAlive: false }), +}); +``` +## Semantic versioning +This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -- Node.js 18+ -- Vercel -- Cloudflare Workers -- Deno v1.25+ -- Bun 1.0+ -- React Native +1. Changes that only affect static types, without breaking runtime behavior. +2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +3. Changes that we do not expect to impact the vast majority of users in practice. -### Customizing Fetch Client +We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -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. +We are keen for your feedback; please open an [issue](https://www.github.com/intercom/intercom-node/issues) with questions, bugs, or suggestions. -```typescript -import { IntercomClient } from "intercom-client"; +## Requirements -const client = new IntercomClient({ - ... - fetcher: // provide your implementation here -}); -``` +TypeScript >= 4.5 is supported. -## Contributing +The following runtimes are supported: -While we value open-source contributions to this SDK, this library is generated programmatically. -Additions made directly to this library would have to be moved over to our generation code, -otherwise they would be overwritten upon the next generated release. Feel free to open a PR as -a proof of concept, but know that we will not be able to merge it as-is. We suggest opening -an issue first to discuss with us! +Note that React Native is not supported at this time. -On the other hand, contributions to the README are always very welcome! \ No newline at end of file +If you are interested in other runtime environments, please open or upvote an issue on GitHub. diff --git a/REPO_OWNER b/REPO_OWNER deleted file mode 100644 index 4ab21abd..00000000 --- a/REPO_OWNER +++ /dev/null @@ -1 +0,0 @@ -team-data-interop diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..01b24280 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainlessapi.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Intercom please follow the respective company's security reporting guidelines. + +### Intercom Terms and Policies + +Please contact dev-feedback@intercom.com for any questions or concerns regarding security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/api.md b/api.md new file mode 100644 index 00000000..8acece46 --- /dev/null +++ b/api.md @@ -0,0 +1,484 @@ +# Shared + +Types: + +- Admin +- ArticleContent +- ArticleTranslatedContent +- Company +- Contact +- ContactReference +- Conversation +- CursorPages +- GroupContent +- GroupTranslatedContent +- Message +- MultipleFilterSearchRequest +- Note +- PartAttachment +- Reference +- SearchRequest +- SingleFilterSearchRequest +- StartingAfterPaging +- SubscriptionTypeList +- Tag +- TagList +- Ticket +- TicketTypeAttribute + +# Me + +Types: + +- AdminWithApp + +Methods: + +- client.me.retrieve({ ...params }) -> AdminWithApp | null + +# Admins + +Types: + +- AdminList + +Methods: + +- client.admins.retrieve(id, { ...params }) -> Admin | null +- client.admins.list({ ...params }) -> AdminList +- client.admins.setAway(id, { ...params }) -> Admin | null + +## ActivityLogs + +Types: + +- ActivityLogList + +Methods: + +- client.admins.activityLogs.list({ ...params }) -> ActivityLogList + +# Articles + +Types: + +- Article +- ArticleList +- ArticleSearchResponse +- DeletedArticleObject + +Methods: + +- client.articles.create({ ...params }) -> Article +- client.articles.retrieve(id, { ...params }) -> Article +- client.articles.update(id, { ...params }) -> Article +- client.articles.list({ ...params }) -> ArticleList +- client.articles.remove(id, { ...params }) -> DeletedArticleObject +- client.articles.search({ ...params }) -> ArticleSearchResponse + +# HelpCenter + +Types: + +- HelpCenter +- HelpCenterList + +## Collections + +Types: + +- Collection +- CollectionList +- DeletedCollection + +Methods: + +- client.helpCenter.collections.create({ ...params }) -> Collection +- client.helpCenter.collections.retrieve(id, { ...params }) -> Collection +- client.helpCenter.collections.update(id, { ...params }) -> Collection +- client.helpCenter.collections.list({ ...params }) -> CollectionList +- client.helpCenter.collections.delete(id, { ...params }) -> DeletedCollection + +## HelpCenters + +Methods: + +- client.helpCenter.helpCenters.retrieve(id, { ...params }) -> HelpCenter +- client.helpCenter.helpCenters.list({ ...params }) -> HelpCenterList + +# Companies + +Types: + +- CompanyList +- CompanyScroll +- DeletedCompanyObject + +Methods: + +- client.companies.create({ ...params }) -> Company +- client.companies.retrieve(id, { ...params }) -> Company +- client.companies.update(id, { ...params }) -> Company +- client.companies.list({ ...params }) -> CompanyList +- client.companies.delete(id, { ...params }) -> DeletedCompanyObject +- client.companies.retrieveList({ ...params }) -> CompanyList +- client.companies.scroll({ ...params }) -> CompanyScroll | null + +## Contacts + +Types: + +- CompanyAttachedContacts + +Methods: + +- client.companies.contacts.list(id, { ...params }) -> CompanyAttachedContacts + +## Segments + +Types: + +- CompanyAttachedSegments + +Methods: + +- client.companies.segments.list(id, { ...params }) -> CompanyAttachedSegments + +# Contacts + +Types: + +- ContactArchived +- ContactDeleted +- ContactList +- ContactUnarchived + +Methods: + +- client.contacts.create({ ...params }) -> Contact +- client.contacts.retrieve(id, { ...params }) -> Contact +- client.contacts.update(id, { ...params }) -> Contact +- client.contacts.list({ ...params }) -> ContactList +- client.contacts.delete(id, { ...params }) -> ContactDeleted +- client.contacts.archive(id, { ...params }) -> ContactArchived +- client.contacts.merge({ ...params }) -> Contact +- client.contacts.search({ ...params }) -> ContactList +- client.contacts.unarchive(id, { ...params }) -> ContactUnarchived + +## Companies + +Types: + +- ContactAttachedCompanies + +Methods: + +- client.contacts.companies.create(contactId, { ...params }) -> Company +- client.contacts.companies.list(contactId, { ...params }) -> ContactAttachedCompanies +- client.contacts.companies.delete(contactId, id, { ...params }) -> Company + +## Notes + +Types: + +- NoteList + +Methods: + +- client.contacts.notes.create(id, { ...params }) -> Note +- client.contacts.notes.list(id, { ...params }) -> NoteList + +## Segments + +Types: + +- ContactSegments + +Methods: + +- client.contacts.segments.list(contactId, { ...params }) -> ContactSegments + +## Subscriptions + +Types: + +- SubscriptionType + +Methods: + +- client.contacts.subscriptions.create(contactId, { ...params }) -> SubscriptionType +- client.contacts.subscriptions.list(contactId, { ...params }) -> SubscriptionTypeList +- client.contacts.subscriptions.delete(contactId, id, { ...params }) -> SubscriptionType + +## Tags + +Methods: + +- client.contacts.tags.create(contactId, { ...params }) -> Tag +- client.contacts.tags.list(contactId, { ...params }) -> TagList +- client.contacts.tags.delete(contactId, id, { ...params }) -> Tag + +# Conversations + +Types: + +- ConversationListResponse +- ConversationSearchResponse + +Methods: + +- client.conversations.create({ ...params }) -> Message +- client.conversations.retrieve(id, { ...params }) -> Conversation +- client.conversations.update(id, { ...params }) -> Conversation +- client.conversations.list({ ...params }) -> ConversationListResponsesCursorPagination +- client.conversations.convert(id, { ...params }) -> Ticket | null +- client.conversations.redact({ ...params }) -> Conversation +- client.conversations.search({ ...params }) -> ConversationSearchResponse + +## Tags + +Methods: + +- client.conversations.tags.create(conversationId, { ...params }) -> Tag +- client.conversations.tags.delete(conversationId, id, { ...params }) -> Tag + +## Reply + +Methods: + +- client.conversations.reply.create(id, { ...params }) -> Conversation + +## Parts + +Methods: + +- client.conversations.parts.create(id, { ...params }) -> Conversation + +## RunAssignmentRules + +Methods: + +- client.conversations.runAssignmentRules.create(id, { ...params }) -> Conversation + +## Customers + +Methods: + +- client.conversations.customers.create(id, { ...params }) -> Conversation +- client.conversations.customers.delete(conversationId, contactId, { ...params }) -> Conversation + +# DataAttributes + +Types: + +- DataAttribute +- DataAttributeList + +Methods: + +- client.dataAttributes.create({ ...params }) -> DataAttribute +- client.dataAttributes.update(id, { ...params }) -> DataAttribute +- client.dataAttributes.list({ ...params }) -> DataAttributeList + +# DataEvents + +Types: + +- DataEventSummary + +Methods: + +- client.dataEvents.create({ ...params }) -> void +- client.dataEvents.list({ ...params }) -> DataEventSummary +- client.dataEvents.summaries({ ...params }) -> void + +# DataExports + +Types: + +- DataExport + +Methods: + +- client.dataExports.contentData({ ...params }) -> DataExport + +# Export + +Methods: + +- client.export.cancel(jobIdentifier, { ...params }) -> DataExport + +## Content + +### Data + +Methods: + +- client.export.content.data.retrieve(jobIdentifier, { ...params }) -> DataExport + +# Download + +## Content + +### Data + +Methods: + +- client.download.content.data.retrieve(jobIdentifier, { ...params }) -> void + +# Messages + +Methods: + +- client.messages.create({ ...params }) -> Message + +# News + +## NewsItems + +Types: + +- NewsItem +- NewsItemListResponse +- NewsItemDeleteResponse + +Methods: + +- client.news.newsItems.create({ ...params }) -> NewsItem +- client.news.newsItems.retrieve(id, { ...params }) -> NewsItem +- client.news.newsItems.update(id, { ...params }) -> NewsItem +- client.news.newsItems.list({ ...params }) -> NewsItemListResponse +- client.news.newsItems.delete(id, { ...params }) -> NewsItemDeleteResponse + +## Newsfeeds + +Types: + +- Newsfeed +- NewsfeedListResponse + +Methods: + +- client.news.newsfeeds.retrieve(id, { ...params }) -> Newsfeed +- client.news.newsfeeds.list({ ...params }) -> NewsfeedListResponse + +### Items + +Types: + +- ItemListResponse + +Methods: + +- client.news.newsfeeds.items.list(id, { ...params }) -> ItemListResponse + +# Notes + +Methods: + +- client.notes.retrieve(id, { ...params }) -> Note + +# Segments + +Types: + +- Segment +- SegmentList + +Methods: + +- client.segments.retrieve(id, { ...params }) -> Segment +- client.segments.list({ ...params }) -> SegmentList + +# SubscriptionTypes + +Methods: + +- client.subscriptionTypes.list({ ...params }) -> SubscriptionTypeList + +# PhoneCallRedirects + +Types: + +- PhoneSwitch + +Methods: + +- client.phoneCallRedirects.create({ ...params }) -> PhoneSwitch | null + +# Tags + +Methods: + +- client.tags.retrieve(id, { ...params }) -> Tag +- client.tags.list({ ...params }) -> TagList +- client.tags.delete(id, { ...params }) -> void +- client.tags.createOrUpdate({ ...params }) -> Tag + +# Teams + +Types: + +- Team +- TeamList + +Methods: + +- client.teams.retrieve(id, { ...params }) -> Team +- client.teams.list({ ...params }) -> TeamList + +# TicketTypes + +Types: + +- TicketType +- TicketTypeList + +Methods: + +- client.ticketTypes.create({ ...params }) -> TicketType | null +- client.ticketTypes.retrieve(id, { ...params }) -> TicketType | null +- client.ticketTypes.update(id, { ...params }) -> TicketType | null +- client.ticketTypes.list({ ...params }) -> TicketTypeList + +## Attributes + +Methods: + +- client.ticketTypes.attributes.create(ticketTypeId, { ...params }) -> TicketTypeAttribute | null +- client.ticketTypes.attributes.update(ticketTypeId, id, { ...params }) -> TicketTypeAttribute | null + +# Tickets + +Types: + +- TicketList +- TicketReply + +Methods: + +- client.tickets.create({ ...params }) -> Ticket | null +- client.tickets.reply(id, { ...params }) -> TicketReply +- client.tickets.retrieveById(id, { ...params }) -> Ticket | null +- client.tickets.search({ ...params }) -> TicketList +- client.tickets.updateById(id, { ...params }) -> Ticket | null + +## Tags + +Methods: + +- client.tickets.tags.create(ticketId, { ...params }) -> Tag +- client.tickets.tags.remove(ticketId, id, { ...params }) -> Tag + +# Visitors + +Types: + +- Visitor +- VisitorDeletedObject + +Methods: + +- client.visitors.retrieve({ ...params }) -> Visitor | null +- client.visitors.update({ ...params }) -> Visitor | null +- client.visitors.convert({ ...params }) -> Contact diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..44f6793a --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${NPM_TOKEN}" ]; then + errors+=("The INTERCOM_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/bin/publish-npm b/bin/publish-npm new file mode 100644 index 00000000..4c21181b --- /dev/null +++ b/bin/publish-npm @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -eux + +npm config set '//registry.npmjs.org/:_authToken' "$NPM_TOKEN" + +# Build the project +yarn build + +# Navigate to the dist directory +cd dist + +# Get the version from package.json +VERSION="$(node -p "require('./package.json').version")" + +# Extract the pre-release tag if it exists +if [[ "$VERSION" =~ -([a-zA-Z]+) ]]; then + # Extract the part before any dot in the pre-release identifier + TAG="${BASH_REMATCH[1]}" +else + TAG="latest" +fi + +# Publish with the appropriate tag +yarn publish --access public --tag "$TAG" diff --git a/biome.json b/biome.json deleted file mode 100644 index a777468e..00000000 --- a/biome.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/2.3.1/schema.json", - "root": true, - "vcs": { - "enabled": false - }, - "files": { - "ignoreUnknown": true, - "includes": [ - "**", - "!!dist", - "!!**/dist", - "!!lib", - "!!**/lib", - "!!_tmp_*", - "!!**/_tmp_*", - "!!*.tmp", - "!!**/*.tmp", - "!!.tmp/", - "!!**/.tmp/", - "!!*.log", - "!!**/*.log", - "!!**/.DS_Store", - "!!**/Thumbs.db" - ] - }, - "formatter": { - "enabled": true, - "indentStyle": "space", - "indentWidth": 4, - "lineWidth": 120 - }, - "javascript": { - "formatter": { - "quoteStyle": "double" - } - }, - "assist": { - "enabled": true, - "actions": { - "source": { - "organizeImports": "on" - } - } - }, - "linter": { - "rules": { - "style": { - "useNodejsImportProtocol": "off" - }, - "suspicious": { - "noAssignInExpressions": "warn", - "noUselessEscapeInString": { - "level": "warn", - "fix": "none", - "options": {} - }, - "noThenProperty": "warn", - "useIterableCallbackReturn": "warn", - "noShadowRestrictedNames": "warn", - "noTsIgnore": { - "level": "warn", - "fix": "none", - "options": {} - }, - "noConfusingVoidType": { - "level": "warn", - "fix": "none", - "options": {} - } - } - } - } -} diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 00000000..0651c89c --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. diff --git a/examples/demo.ts b/examples/demo.ts new file mode 100644 index 00000000..fce0ecc1 --- /dev/null +++ b/examples/demo.ts @@ -0,0 +1,33 @@ +#!/usr/bin/env -S npm run tsn -T + +// INTERCOM_TEST_1_BEARER_TOKEN=*** pnpm tsn -T examples/demo.ts + +import Intercom from 'intercom'; + +const intercom = new Intercom(); +const demoId = Math.floor(Math.random() * 10000); + +async function main() { + // Check account info + const me = await intercom.me.retrieve({ 'Intercom-Version': '2.10' }); + console.log(`Requesting as ${me?.name} (${me?.email})\n`); + + // Check contacts + let contacts = await intercom.contacts.list({ 'Intercom-Version': '2.10' }); + console.log(`Contact count: ${contacts.data?.length}`); + console.log(`${contacts.data?.map((contact) => `\t${contact.email}`).join('\n')}\n`); + + // Add contact + const newEmail = `alex${demoId}@stainlessapi.com`; + console.log(`Adding new contact ${newEmail}`); + const createdContact = await intercom.contacts.create({ + name: 'Alex', + email: newEmail, + 'Intercom-Version': '2.10', + }); + console.log(`Created contact with ID ${createdContact.id}`); +} + +main().catch((err) => { + console.error(err); +}); diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 00000000..914033c6 --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,23 @@ +import type { JestConfigWithTsJest } from 'ts-jest'; + +const config: JestConfigWithTsJest = { + preset: 'ts-jest/presets/default-esm', + testEnvironment: 'node', + transform: { + '^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }], + }, + moduleNameMapper: { + '^intercom-client$': '/src/index.ts', + '^intercom-client/_shims/auto/(.*)$': '/src/_shims/auto/$1-node', + '^intercom-client/(.*)$': '/src/$1', + }, + modulePathIgnorePatterns: [ + '/ecosystem-tests/', + '/dist/', + '/deno/', + '/deno_tests/', + ], + testPathIgnorePatterns: ['scripts'], +}; + +export default config; diff --git a/package.json b/package.json index 8bcf8e0c..4224de77 100644 --- a/package.json +++ b/package.json @@ -1,74 +1,125 @@ { - "name": "intercom-client", - "version": "7.0.3", - "private": false, - "repository": "github:intercom/intercom-node", - "type": "commonjs", - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.mjs", - "types": "./dist/cjs/index.d.ts", - "exports": { - ".": { - "types": "./dist/cjs/index.d.ts", - "import": { - "types": "./dist/esm/index.d.mts", - "default": "./dist/esm/index.mjs" - }, - "require": { - "types": "./dist/cjs/index.d.ts", - "default": "./dist/cjs/index.js" - }, - "default": "./dist/cjs/index.js" - }, - "./package.json": "./package.json" + "name": "intercom-client", + "version": "6.0.0-beta.3", + "description": "The official TypeScript library for the Intercom API", + "author": "Intercom ", + "types": "dist/index.d.ts", + "main": "dist/index.js", + "type": "commonjs", + "repository": "github:intercom/intercom-node", + "license": "Apache-2.0", + "packageManager": "yarn@1.22.22", + "files": [ + "*" + ], + "private": false, + "scripts": { + "test": "./scripts/test", + "build": "./scripts/build", + "prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1", + "format": "prettier --write --cache --cache-strategy metadata . !dist", + "prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi", + "tsn": "ts-node -r tsconfig-paths/register", + "lint": "./scripts/lint", + "fix": "eslint --fix --ext ts,js ." + }, + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "@types/qs": "^6.9.7", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "qs": "^6.10.3" + }, + "devDependencies": { + "@swc/core": "^1.3.102", + "@swc/jest": "^0.2.29", + "@types/jest": "^29.4.0", + "@typescript-eslint/eslint-plugin": "^6.7.0", + "@typescript-eslint/parser": "^6.7.0", + "eslint": "^8.49.0", + "eslint-plugin-prettier": "^5.0.1", + "eslint-plugin-unused-imports": "^3.0.0", + "jest": "^29.4.0", + "prettier": "^3.0.0", + "ts-jest": "^29.1.0", + "ts-morph": "^19.0.0", + "ts-node": "^10.5.0", + "tsc-multi": "^1.1.0", + "tsconfig-paths": "^4.0.0", + "typescript": "^4.8.2" + }, + "sideEffects": [ + "./_shims/index.js", + "./_shims/index.mjs", + "./shims/node.js", + "./shims/node.mjs", + "./shims/web.js", + "./shims/web.mjs" + ], + "imports": { + "intercom-client": ".", + "intercom-client/*": "./src/*" + }, + "exports": { + "./_shims/auto/*": { + "deno": { + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*.js", + "default": "./dist/_shims/auto/*.mjs" + }, + "bun": { + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*-bun.js", + "default": "./dist/_shims/auto/*-bun.mjs" + }, + "browser": { + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*.js", + "default": "./dist/_shims/auto/*.mjs" + }, + "worker": { + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*.js", + "default": "./dist/_shims/auto/*.mjs" + }, + "workerd": { + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*.js", + "default": "./dist/_shims/auto/*.mjs" + }, + "node": { + "types": "./dist/_shims/auto/*-node.d.ts", + "require": "./dist/_shims/auto/*-node.js", + "default": "./dist/_shims/auto/*-node.mjs" + }, + "types": "./dist/_shims/auto/*.d.ts", + "require": "./dist/_shims/auto/*.js", + "default": "./dist/_shims/auto/*.mjs" }, - "files": [ - "dist", - "reference.md", - "README.md", - "LICENSE" - ], - "scripts": { - "format": "biome format --write --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "format:check": "biome format --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "lint": "biome lint --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "lint:fix": "biome lint --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none", - "build": "pnpm build:cjs && pnpm build:esm", - "build:cjs": "tsc --project ./tsconfig.cjs.json", - "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm", - "test": "vitest", - "test:unit": "vitest --project unit", - "test:wire": "vitest --project wire" + ".": { + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" }, - "dependencies": {}, - "devDependencies": { - "webpack": "^5.97.1", - "ts-loader": "^9.5.1", - "vitest": "^3.2.4", - "msw": "2.11.2", - "@types/node": "^18.19.70", - "typescript": "~5.7.2", - "@biomejs/biome": "2.3.1" + "./*.mjs": { + "types": "./dist/*.d.ts", + "default": "./dist/*.mjs" }, - "browser": { - "fs": false, - "os": false, - "path": false, - "stream": false + "./*.js": { + "types": "./dist/*.d.ts", + "default": "./dist/*.js" }, - "packageManager": "pnpm@10.20.0", - "engines": { - "node": ">=18.0.0" - }, - "sideEffects": false, - "license": "Apache-2.0", - "description": "Official Node bindings to the Intercom API", - "homepage": "https://github.com/intercom/intercom-node", - "bugs": "https://github.com/intercom/intercom-node/issues", - "keywords": [ - "intercom", - "api" - ] + "./*": { + "types": "./dist/*.d.ts", + "require": "./dist/*.js", + "default": "./dist/*.mjs" + } + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml deleted file mode 100644 index b6c82556..00000000 --- a/pnpm-lock.yaml +++ /dev/null @@ -1,2146 +0,0 @@ -lockfileVersion: '9.0' - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - -importers: - - .: - devDependencies: - '@biomejs/biome': - specifier: 2.3.1 - version: 2.3.1 - '@types/node': - specifier: ^18.19.70 - version: 18.19.130 - msw: - specifier: 2.11.2 - version: 2.11.2(@types/node@18.19.130)(typescript@5.7.3) - ts-loader: - specifier: ^9.5.1 - version: 9.5.4(typescript@5.7.3)(webpack@5.104.1) - typescript: - specifier: ~5.7.2 - version: 5.7.3 - vitest: - specifier: ^3.2.4 - version: 3.2.4(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(terser@5.46.0) - webpack: - specifier: ^5.97.1 - version: 5.104.1 - -packages: - - '@biomejs/biome@2.3.1': - resolution: {integrity: sha512-A29evf1R72V5bo4o2EPxYMm5mtyGvzp2g+biZvRFx29nWebGyyeOSsDWGx3tuNNMFRepGwxmA9ZQ15mzfabK2w==} - engines: {node: '>=14.21.3'} - hasBin: true - - '@biomejs/cli-darwin-arm64@2.3.1': - resolution: {integrity: sha512-ombSf3MnTUueiYGN1SeI9tBCsDUhpWzOwS63Dove42osNh0PfE1cUtHFx6eZ1+MYCCLwXzlFlYFdrJ+U7h6LcA==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [darwin] - - '@biomejs/cli-darwin-x64@2.3.1': - resolution: {integrity: sha512-pcOfwyoQkrkbGvXxRvZNe5qgD797IowpJPovPX5biPk2FwMEV+INZqfCaz4G5bVq9hYnjwhRMamg11U4QsRXrQ==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [darwin] - - '@biomejs/cli-linux-arm64-musl@2.3.1': - resolution: {integrity: sha512-+DZYv8l7FlUtTrWs1Tdt1KcNCAmRO87PyOnxKGunbWm5HKg1oZBSbIIPkjrCtDZaeqSG1DiGx7qF+CPsquQRcg==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-arm64@2.3.1': - resolution: {integrity: sha512-td5O8pFIgLs8H1sAZsD6v+5quODihyEw4nv2R8z7swUfIK1FKk+15e4eiYVLcAE4jUqngvh4j3JCNgg0Y4o4IQ==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-x64-musl@2.3.1': - resolution: {integrity: sha512-Y3Ob4nqgv38Mh+6EGHltuN+Cq8aj/gyMTJYzkFZV2AEj+9XzoXB9VNljz9pjfFNHUxvLEV4b55VWyxozQTBaUQ==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-linux-x64@2.3.1': - resolution: {integrity: sha512-PYWgEO7up7XYwSAArOpzsVCiqxBCXy53gsReAb1kKYIyXaoAlhBaBMvxR/k2Rm9aTuZ662locXUmPk/Aj+Xu+Q==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-win32-arm64@2.3.1': - resolution: {integrity: sha512-RHIG/zgo+69idUqVvV3n8+j58dKYABRpMyDmfWu2TITC+jwGPiEaT0Q3RKD+kQHiS80mpBrST0iUGeEXT0bU9A==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [win32] - - '@biomejs/cli-win32-x64@2.3.1': - resolution: {integrity: sha512-izl30JJ5Dp10mi90Eko47zhxE6pYyWPcnX1NQxKpL/yMhXxf95oLTzfpu4q+MDBh/gemNqyJEwjBpe0MT5iWPA==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [win32] - - '@bundled-es-modules/cookie@2.0.1': - resolution: {integrity: sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==} - - '@bundled-es-modules/statuses@1.0.1': - resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} - - '@esbuild/aix-ppc64@0.25.12': - resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [aix] - - '@esbuild/android-arm64@0.25.12': - resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [android] - - '@esbuild/android-arm@0.25.12': - resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} - engines: {node: '>=18'} - cpu: [arm] - os: [android] - - '@esbuild/android-x64@0.25.12': - resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} - engines: {node: '>=18'} - cpu: [x64] - os: [android] - - '@esbuild/darwin-arm64@0.25.12': - resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [darwin] - - '@esbuild/darwin-x64@0.25.12': - resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} - engines: {node: '>=18'} - cpu: [x64] - os: [darwin] - - '@esbuild/freebsd-arm64@0.25.12': - resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [freebsd] - - '@esbuild/freebsd-x64@0.25.12': - resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} - engines: {node: '>=18'} - cpu: [x64] - os: [freebsd] - - '@esbuild/linux-arm64@0.25.12': - resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} - engines: {node: '>=18'} - cpu: [arm64] - os: [linux] - - '@esbuild/linux-arm@0.25.12': - resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} - engines: {node: '>=18'} - cpu: [arm] - os: [linux] - - '@esbuild/linux-ia32@0.25.12': - resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} - engines: {node: '>=18'} - cpu: [ia32] - os: [linux] - - '@esbuild/linux-loong64@0.25.12': - resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} - engines: {node: '>=18'} - cpu: [loong64] - os: [linux] - - '@esbuild/linux-mips64el@0.25.12': - resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} - engines: {node: '>=18'} - cpu: [mips64el] - os: [linux] - - '@esbuild/linux-ppc64@0.25.12': - resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} - engines: {node: '>=18'} - cpu: [ppc64] - os: [linux] - - '@esbuild/linux-riscv64@0.25.12': - resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} - engines: {node: '>=18'} - cpu: [riscv64] - os: [linux] - - '@esbuild/linux-s390x@0.25.12': - resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} - engines: {node: '>=18'} - cpu: [s390x] - os: [linux] - - '@esbuild/linux-x64@0.25.12': - resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} - engines: {node: '>=18'} - cpu: [x64] - os: [linux] - - '@esbuild/netbsd-arm64@0.25.12': - resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [netbsd] - - '@esbuild/netbsd-x64@0.25.12': - resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} - engines: {node: '>=18'} - cpu: [x64] - os: [netbsd] - - '@esbuild/openbsd-arm64@0.25.12': - resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openbsd] - - '@esbuild/openbsd-x64@0.25.12': - resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} - engines: {node: '>=18'} - cpu: [x64] - os: [openbsd] - - '@esbuild/openharmony-arm64@0.25.12': - resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [openharmony] - - '@esbuild/sunos-x64@0.25.12': - resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} - engines: {node: '>=18'} - cpu: [x64] - os: [sunos] - - '@esbuild/win32-arm64@0.25.12': - resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} - engines: {node: '>=18'} - cpu: [arm64] - os: [win32] - - '@esbuild/win32-ia32@0.25.12': - resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} - engines: {node: '>=18'} - cpu: [ia32] - os: [win32] - - '@esbuild/win32-x64@0.25.12': - resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} - engines: {node: '>=18'} - cpu: [x64] - os: [win32] - - '@inquirer/ansi@1.0.2': - resolution: {integrity: sha512-S8qNSZiYzFd0wAcyG5AXCvUHC5Sr7xpZ9wZ2py9XR88jUz8wooStVx5M6dRzczbBWjic9NP7+rY0Xi7qqK/aMQ==} - engines: {node: '>=18'} - - '@inquirer/confirm@5.1.21': - resolution: {integrity: sha512-KR8edRkIsUayMXV+o3Gv+q4jlhENF9nMYUZs9PA2HzrXeHI8M5uDag70U7RJn9yyiMZSbtF5/UexBtAVtZGSbQ==} - engines: {node: '>=18'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true - - '@inquirer/core@10.3.2': - resolution: {integrity: sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A==} - engines: {node: '>=18'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true - - '@inquirer/figures@1.0.15': - resolution: {integrity: sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==} - engines: {node: '>=18'} - - '@inquirer/type@3.0.10': - resolution: {integrity: sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA==} - engines: {node: '>=18'} - peerDependencies: - '@types/node': '>=18' - peerDependenciesMeta: - '@types/node': - optional: true - - '@jridgewell/gen-mapping@0.3.13': - resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} - - '@jridgewell/resolve-uri@3.1.2': - resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} - engines: {node: '>=6.0.0'} - - '@jridgewell/source-map@0.3.11': - resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==} - - '@jridgewell/sourcemap-codec@1.5.5': - resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} - - '@jridgewell/trace-mapping@0.3.31': - resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} - - '@mswjs/interceptors@0.39.8': - resolution: {integrity: sha512-2+BzZbjRO7Ct61k8fMNHEtoKjeWI9pIlHFTqBwZ5icHpqszIgEZbjb1MW5Z0+bITTCTl3gk4PDBxs9tA/csXvA==} - engines: {node: '>=18'} - - '@open-draft/deferred-promise@2.2.0': - resolution: {integrity: sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==} - - '@open-draft/logger@0.3.0': - resolution: {integrity: sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==} - - '@open-draft/until@2.1.0': - resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==} - - '@rollup/rollup-android-arm-eabi@4.53.3': - resolution: {integrity: sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==} - cpu: [arm] - os: [android] - - '@rollup/rollup-android-arm64@4.53.3': - resolution: {integrity: sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==} - cpu: [arm64] - os: [android] - - '@rollup/rollup-darwin-arm64@4.53.3': - resolution: {integrity: sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==} - cpu: [arm64] - os: [darwin] - - '@rollup/rollup-darwin-x64@4.53.3': - resolution: {integrity: sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==} - cpu: [x64] - os: [darwin] - - '@rollup/rollup-freebsd-arm64@4.53.3': - resolution: {integrity: sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==} - cpu: [arm64] - os: [freebsd] - - '@rollup/rollup-freebsd-x64@4.53.3': - resolution: {integrity: sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==} - cpu: [x64] - os: [freebsd] - - '@rollup/rollup-linux-arm-gnueabihf@4.53.3': - resolution: {integrity: sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm-musleabihf@4.53.3': - resolution: {integrity: sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==} - cpu: [arm] - os: [linux] - - '@rollup/rollup-linux-arm64-gnu@4.53.3': - resolution: {integrity: sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-arm64-musl@4.53.3': - resolution: {integrity: sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==} - cpu: [arm64] - os: [linux] - - '@rollup/rollup-linux-loong64-gnu@4.53.3': - resolution: {integrity: sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==} - cpu: [loong64] - os: [linux] - - '@rollup/rollup-linux-ppc64-gnu@4.53.3': - resolution: {integrity: sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==} - cpu: [ppc64] - os: [linux] - - '@rollup/rollup-linux-riscv64-gnu@4.53.3': - resolution: {integrity: sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==} - cpu: [riscv64] - os: [linux] - - '@rollup/rollup-linux-riscv64-musl@4.53.3': - resolution: {integrity: sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==} - cpu: [riscv64] - os: [linux] - - '@rollup/rollup-linux-s390x-gnu@4.53.3': - resolution: {integrity: sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==} - cpu: [s390x] - os: [linux] - - '@rollup/rollup-linux-x64-gnu@4.53.3': - resolution: {integrity: sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-linux-x64-musl@4.53.3': - resolution: {integrity: sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==} - cpu: [x64] - os: [linux] - - '@rollup/rollup-openharmony-arm64@4.53.3': - resolution: {integrity: sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==} - cpu: [arm64] - os: [openharmony] - - '@rollup/rollup-win32-arm64-msvc@4.53.3': - resolution: {integrity: sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==} - cpu: [arm64] - os: [win32] - - '@rollup/rollup-win32-ia32-msvc@4.53.3': - resolution: {integrity: sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==} - cpu: [ia32] - os: [win32] - - '@rollup/rollup-win32-x64-gnu@4.53.3': - resolution: {integrity: sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==} - cpu: [x64] - os: [win32] - - '@rollup/rollup-win32-x64-msvc@4.53.3': - resolution: {integrity: sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==} - cpu: [x64] - os: [win32] - - '@types/chai@5.2.3': - resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} - - '@types/cookie@0.6.0': - resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} - - '@types/deep-eql@4.0.2': - resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} - - '@types/eslint-scope@3.7.7': - resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} - - '@types/eslint@9.6.1': - resolution: {integrity: sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==} - - '@types/estree@1.0.8': - resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} - - '@types/json-schema@7.0.15': - resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - - '@types/node@18.19.130': - resolution: {integrity: sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==} - - '@types/statuses@2.0.6': - resolution: {integrity: sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==} - - '@vitest/expect@3.2.4': - resolution: {integrity: sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==} - - '@vitest/mocker@3.2.4': - resolution: {integrity: sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==} - peerDependencies: - msw: ^2.4.9 - vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0 - peerDependenciesMeta: - msw: - optional: true - vite: - optional: true - - '@vitest/pretty-format@3.2.4': - resolution: {integrity: sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==} - - '@vitest/runner@3.2.4': - resolution: {integrity: sha512-oukfKT9Mk41LreEW09vt45f8wx7DordoWUZMYdY/cyAk7w5TWkTRCNZYF7sX7n2wB7jyGAl74OxgwhPgKaqDMQ==} - - '@vitest/snapshot@3.2.4': - resolution: {integrity: sha512-dEYtS7qQP2CjU27QBC5oUOxLE/v5eLkGqPE0ZKEIDGMs4vKWe7IjgLOeauHsR0D5YuuycGRO5oSRXnwnmA78fQ==} - - '@vitest/spy@3.2.4': - resolution: {integrity: sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==} - - '@vitest/utils@3.2.4': - resolution: {integrity: sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==} - - '@webassemblyjs/ast@1.14.1': - resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==} - - '@webassemblyjs/floating-point-hex-parser@1.13.2': - resolution: {integrity: sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==} - - '@webassemblyjs/helper-api-error@1.13.2': - resolution: {integrity: sha512-U56GMYxy4ZQCbDZd6JuvvNV/WFildOjsaWD3Tzzvmw/mas3cXzRJPMjP83JqEsgSbyrmaGjBfDtV7KDXV9UzFQ==} - - '@webassemblyjs/helper-buffer@1.14.1': - resolution: {integrity: sha512-jyH7wtcHiKssDtFPRB+iQdxlDf96m0E39yb0k5uJVhFGleZFoNw1c4aeIcVUPPbXUVJ94wwnMOAqUHyzoEPVMA==} - - '@webassemblyjs/helper-numbers@1.13.2': - resolution: {integrity: sha512-FE8aCmS5Q6eQYcV3gI35O4J789wlQA+7JrqTTpJqn5emA4U2hvwJmvFRC0HODS+3Ye6WioDklgd6scJ3+PLnEA==} - - '@webassemblyjs/helper-wasm-bytecode@1.13.2': - resolution: {integrity: sha512-3QbLKy93F0EAIXLh0ogEVR6rOubA9AoZ+WRYhNbFyuB70j3dRdwH9g+qXhLAO0kiYGlg3TxDV+I4rQTr/YNXkA==} - - '@webassemblyjs/helper-wasm-section@1.14.1': - resolution: {integrity: sha512-ds5mXEqTJ6oxRoqjhWDU83OgzAYjwsCV8Lo/N+oRsNDmx/ZDpqalmrtgOMkHwxsG0iI//3BwWAErYRHtgn0dZw==} - - '@webassemblyjs/ieee754@1.13.2': - resolution: {integrity: sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==} - - '@webassemblyjs/leb128@1.13.2': - resolution: {integrity: sha512-Lde1oNoIdzVzdkNEAWZ1dZ5orIbff80YPdHx20mrHwHrVNNTjNr8E3xz9BdpcGqRQbAEa+fkrCb+fRFTl/6sQw==} - - '@webassemblyjs/utf8@1.13.2': - resolution: {integrity: sha512-3NQWGjKTASY1xV5m7Hr0iPeXD9+RDobLll3T9d2AO+g3my8xy5peVyjSag4I50mR1bBSN/Ct12lo+R9tJk0NZQ==} - - '@webassemblyjs/wasm-edit@1.14.1': - resolution: {integrity: sha512-RNJUIQH/J8iA/1NzlE4N7KtyZNHi3w7at7hDjvRNm5rcUXa00z1vRz3glZoULfJ5mpvYhLybmVcwcjGrC1pRrQ==} - - '@webassemblyjs/wasm-gen@1.14.1': - resolution: {integrity: sha512-AmomSIjP8ZbfGQhumkNvgC33AY7qtMCXnN6bL2u2Js4gVCg8fp735aEiMSBbDR7UQIj90n4wKAFUSEd0QN2Ukg==} - - '@webassemblyjs/wasm-opt@1.14.1': - resolution: {integrity: sha512-PTcKLUNvBqnY2U6E5bdOQcSM+oVP/PmrDY9NzowJjislEjwP/C4an2303MCVS2Mg9d3AJpIGdUFIQQWbPds0Sw==} - - '@webassemblyjs/wasm-parser@1.14.1': - resolution: {integrity: sha512-JLBl+KZ0R5qB7mCnud/yyX08jWFw5MsoalJ1pQ4EdFlgj9VdXKGuENGsiCIjegI1W7p91rUlcB/LB5yRJKNTcQ==} - - '@webassemblyjs/wast-printer@1.14.1': - resolution: {integrity: sha512-kPSSXE6De1XOR820C90RIo2ogvZG+c3KiHzqUoO/F34Y2shGzesfqv7o57xrxovZJH/MetF5UjroJ/R/3isoiw==} - - '@xtuc/ieee754@1.2.0': - resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} - - '@xtuc/long@4.2.2': - resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==} - - acorn-import-phases@1.0.4: - resolution: {integrity: sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==} - engines: {node: '>=10.13.0'} - peerDependencies: - acorn: ^8.14.0 - - acorn@8.15.0: - resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} - engines: {node: '>=0.4.0'} - hasBin: true - - ajv-formats@2.1.1: - resolution: {integrity: sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==} - peerDependencies: - ajv: ^8.0.0 - peerDependenciesMeta: - ajv: - optional: true - - ajv-keywords@5.1.0: - resolution: {integrity: sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==} - peerDependencies: - ajv: ^8.8.2 - - ajv@8.17.1: - resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} - - ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - - ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - - assertion-error@2.0.1: - resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} - engines: {node: '>=12'} - - baseline-browser-mapping@2.9.19: - resolution: {integrity: sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==} - hasBin: true - - braces@3.0.3: - resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} - engines: {node: '>=8'} - - browserslist@4.28.1: - resolution: {integrity: sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA==} - engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} - hasBin: true - - buffer-from@1.1.2: - resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - - cac@6.7.14: - resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} - engines: {node: '>=8'} - - caniuse-lite@1.0.30001769: - resolution: {integrity: sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==} - - chai@5.3.3: - resolution: {integrity: sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==} - engines: {node: '>=18'} - - chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - - check-error@2.1.1: - resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} - engines: {node: '>= 16'} - - chrome-trace-event@1.0.4: - resolution: {integrity: sha512-rNjApaLzuwaOTjCiT8lSDdGN1APCiqkChLMJxJPWLunPAt5fy8xgU9/jNOchV84wfIxrA0lRQB7oCT8jrn/wrQ==} - engines: {node: '>=6.0'} - - cli-width@4.1.0: - resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==} - engines: {node: '>= 12'} - - cliui@8.0.1: - resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} - engines: {node: '>=12'} - - color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - - color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - - commander@2.20.3: - resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} - - cookie@0.7.2: - resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} - engines: {node: '>= 0.6'} - - debug@4.4.3: - resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - - deep-eql@5.0.2: - resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} - engines: {node: '>=6'} - - electron-to-chromium@1.5.286: - resolution: {integrity: sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A==} - - emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - - enhanced-resolve@5.18.3: - resolution: {integrity: sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==} - engines: {node: '>=10.13.0'} - - enhanced-resolve@5.19.0: - resolution: {integrity: sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==} - engines: {node: '>=10.13.0'} - - es-module-lexer@1.7.0: - resolution: {integrity: sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==} - - es-module-lexer@2.0.0: - resolution: {integrity: sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==} - - esbuild@0.25.12: - resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} - engines: {node: '>=18'} - hasBin: true - - escalade@3.2.0: - resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} - engines: {node: '>=6'} - - eslint-scope@5.1.1: - resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} - engines: {node: '>=8.0.0'} - - esrecurse@4.3.0: - resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} - engines: {node: '>=4.0'} - - estraverse@4.3.0: - resolution: {integrity: sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==} - engines: {node: '>=4.0'} - - estraverse@5.3.0: - resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} - engines: {node: '>=4.0'} - - estree-walker@3.0.3: - resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} - - events@3.3.0: - resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} - engines: {node: '>=0.8.x'} - - expect-type@1.2.2: - resolution: {integrity: sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==} - engines: {node: '>=12.0.0'} - - fast-deep-equal@3.1.3: - resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - - fast-uri@3.1.0: - resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} - - fdir@6.5.0: - resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} - engines: {node: '>=12.0.0'} - peerDependencies: - picomatch: ^3 || ^4 - peerDependenciesMeta: - picomatch: - optional: true - - fill-range@7.1.1: - resolution: {integrity: sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==} - engines: {node: '>=8'} - - fsevents@2.3.3: - resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} - engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} - os: [darwin] - - get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - - glob-to-regexp@0.4.1: - resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} - - graceful-fs@4.2.11: - resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} - - graphql@16.12.0: - resolution: {integrity: sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==} - engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} - - has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - - headers-polyfill@4.0.3: - resolution: {integrity: sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ==} - - is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - - is-node-process@1.2.0: - resolution: {integrity: sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==} - - is-number@7.0.0: - resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} - engines: {node: '>=0.12.0'} - - jest-worker@27.5.1: - resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} - engines: {node: '>= 10.13.0'} - - js-tokens@9.0.1: - resolution: {integrity: sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==} - - json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - - json-schema-traverse@1.0.0: - resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - - loader-runner@4.3.1: - resolution: {integrity: sha512-IWqP2SCPhyVFTBtRcgMHdzlf9ul25NwaFx4wCEH/KjAXuuHY4yNjvPXsBokp8jCB936PyWRaPKUNh8NvylLp2Q==} - engines: {node: '>=6.11.5'} - - loupe@3.2.1: - resolution: {integrity: sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==} - - magic-string@0.30.21: - resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} - - merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - - micromatch@4.0.8: - resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} - engines: {node: '>=8.6'} - - mime-db@1.52.0: - resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} - engines: {node: '>= 0.6'} - - mime-types@2.1.35: - resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} - engines: {node: '>= 0.6'} - - ms@2.1.3: - resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - - msw@2.11.2: - resolution: {integrity: sha512-MI54hLCsrMwiflkcqlgYYNJJddY5/+S0SnONvhv1owOplvqohKSQyGejpNdUGyCwgs4IH7PqaNbPw/sKOEze9Q==} - engines: {node: '>=18'} - hasBin: true - peerDependencies: - typescript: '>= 4.8.x' - peerDependenciesMeta: - typescript: - optional: true - - mute-stream@2.0.0: - resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} - engines: {node: ^18.17.0 || >=20.5.0} - - nanoid@3.3.11: - resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} - engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} - hasBin: true - - neo-async@2.6.2: - resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} - - node-releases@2.0.27: - resolution: {integrity: sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA==} - - outvariant@1.4.3: - resolution: {integrity: sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==} - - path-to-regexp@6.3.0: - resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} - - pathe@2.0.3: - resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} - - pathval@2.0.1: - resolution: {integrity: sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==} - engines: {node: '>= 14.16'} - - picocolors@1.1.1: - resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} - - picomatch@2.3.1: - resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} - engines: {node: '>=8.6'} - - picomatch@4.0.3: - resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} - engines: {node: '>=12'} - - postcss@8.5.6: - resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} - engines: {node: ^10 || ^12 || >=14} - - randombytes@2.1.0: - resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} - - require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - - require-from-string@2.0.2: - resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} - engines: {node: '>=0.10.0'} - - rettime@0.7.0: - resolution: {integrity: sha512-LPRKoHnLKd/r3dVxcwO7vhCW+orkOGj9ViueosEBK6ie89CijnfRlhaDhHq/3Hxu4CkWQtxwlBG0mzTQY6uQjw==} - - rollup@4.53.3: - resolution: {integrity: sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - - safe-buffer@5.2.1: - resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - - schema-utils@4.3.3: - resolution: {integrity: sha512-eflK8wEtyOE6+hsaRVPxvUKYCpRgzLqDTb8krvAsRIwOGlHoSgYLgBXoubGgLd2fT41/OUYdb48v4k4WWHQurA==} - engines: {node: '>= 10.13.0'} - - semver@7.7.3: - resolution: {integrity: sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==} - engines: {node: '>=10'} - hasBin: true - - serialize-javascript@6.0.2: - resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} - - siginfo@2.0.0: - resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} - - signal-exit@4.1.0: - resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} - engines: {node: '>=14'} - - source-map-js@1.2.1: - resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} - engines: {node: '>=0.10.0'} - - source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - - source-map@0.6.1: - resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} - engines: {node: '>=0.10.0'} - - source-map@0.7.6: - resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} - engines: {node: '>= 12'} - - stackback@0.0.2: - resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} - - statuses@2.0.2: - resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==} - engines: {node: '>= 0.8'} - - std-env@3.10.0: - resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} - - strict-event-emitter@0.5.1: - resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} - - string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - - strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - - strip-literal@3.1.0: - resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==} - - supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - - supports-color@8.1.1: - resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==} - engines: {node: '>=10'} - - tapable@2.3.0: - resolution: {integrity: sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg==} - engines: {node: '>=6'} - - terser-webpack-plugin@5.3.16: - resolution: {integrity: sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q==} - engines: {node: '>= 10.13.0'} - peerDependencies: - '@swc/core': '*' - esbuild: '*' - uglify-js: '*' - webpack: ^5.1.0 - peerDependenciesMeta: - '@swc/core': - optional: true - esbuild: - optional: true - uglify-js: - optional: true - - terser@5.46.0: - resolution: {integrity: sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg==} - engines: {node: '>=10'} - hasBin: true - - tinybench@2.9.0: - resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} - - tinyexec@0.3.2: - resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} - - tinyglobby@0.2.15: - resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} - engines: {node: '>=12.0.0'} - - tinypool@1.1.1: - resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} - engines: {node: ^18.0.0 || >=20.0.0} - - tinyrainbow@2.0.0: - resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} - engines: {node: '>=14.0.0'} - - tinyspy@4.0.4: - resolution: {integrity: sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==} - engines: {node: '>=14.0.0'} - - tldts-core@7.0.19: - resolution: {integrity: sha512-lJX2dEWx0SGH4O6p+7FPwYmJ/bu1JbcGJ8RLaG9b7liIgZ85itUVEPbMtWRVrde/0fnDPEPHW10ZsKW3kVsE9A==} - - tldts@7.0.19: - resolution: {integrity: sha512-8PWx8tvC4jDB39BQw1m4x8y5MH1BcQ5xHeL2n7UVFulMPH/3Q0uiamahFJ3lXA0zO2SUyRXuVVbWSDmstlt9YA==} - hasBin: true - - to-regex-range@5.0.1: - resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} - engines: {node: '>=8.0'} - - tough-cookie@6.0.0: - resolution: {integrity: sha512-kXuRi1mtaKMrsLUxz3sQYvVl37B0Ns6MzfrtV5DvJceE9bPyspOqk9xxv7XbZWcfLWbFmm997vl83qUWVJA64w==} - engines: {node: '>=16'} - - ts-loader@9.5.4: - resolution: {integrity: sha512-nCz0rEwunlTZiy6rXFByQU1kVVpCIgUpc/psFiKVrUwrizdnIbRFu8w7bxhUF0X613DYwT4XzrZHpVyMe758hQ==} - engines: {node: '>=12.0.0'} - peerDependencies: - typescript: '*' - webpack: ^5.0.0 - - type-fest@4.41.0: - resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} - engines: {node: '>=16'} - - typescript@5.7.3: - resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==} - engines: {node: '>=14.17'} - hasBin: true - - undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - - update-browserslist-db@1.2.3: - resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' - - vite-node@3.2.4: - resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==} - engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} - hasBin: true - - vite@7.2.6: - resolution: {integrity: sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==} - engines: {node: ^20.19.0 || >=22.12.0} - hasBin: true - peerDependencies: - '@types/node': ^20.19.0 || >=22.12.0 - jiti: '>=1.21.0' - less: ^4.0.0 - lightningcss: ^1.21.0 - sass: ^1.70.0 - sass-embedded: ^1.70.0 - stylus: '>=0.54.8' - sugarss: ^5.0.0 - terser: ^5.16.0 - tsx: ^4.8.1 - yaml: ^2.4.2 - peerDependenciesMeta: - '@types/node': - optional: true - jiti: - optional: true - less: - optional: true - lightningcss: - optional: true - sass: - optional: true - sass-embedded: - optional: true - stylus: - optional: true - sugarss: - optional: true - terser: - optional: true - tsx: - optional: true - yaml: - optional: true - - vitest@3.2.4: - resolution: {integrity: sha512-LUCP5ev3GURDysTWiP47wRRUpLKMOfPh+yKTx3kVIEiu5KOMeqzpnYNsKyOoVrULivR8tLcks4+lga33Whn90A==} - engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} - hasBin: true - peerDependencies: - '@edge-runtime/vm': '*' - '@types/debug': ^4.1.12 - '@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0 - '@vitest/browser': 3.2.4 - '@vitest/ui': 3.2.4 - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@edge-runtime/vm': - optional: true - '@types/debug': - optional: true - '@types/node': - optional: true - '@vitest/browser': - optional: true - '@vitest/ui': - optional: true - happy-dom: - optional: true - jsdom: - optional: true - - watchpack@2.5.1: - resolution: {integrity: sha512-Zn5uXdcFNIA1+1Ei5McRd+iRzfhENPCe7LeABkJtNulSxjma+l7ltNx55BWZkRlwRnpOgHqxnjyaDgJnNXnqzg==} - engines: {node: '>=10.13.0'} - - webpack-sources@3.3.3: - resolution: {integrity: sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==} - engines: {node: '>=10.13.0'} - - webpack@5.104.1: - resolution: {integrity: sha512-Qphch25abbMNtekmEGJmeRUhLDbe+QfiWTiqpKYkpCOWY64v9eyl+KRRLmqOFA2AvKPpc9DC6+u2n76tQLBoaA==} - engines: {node: '>=10.13.0'} - hasBin: true - peerDependencies: - webpack-cli: '*' - peerDependenciesMeta: - webpack-cli: - optional: true - - why-is-node-running@2.3.0: - resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} - engines: {node: '>=8'} - hasBin: true - - wrap-ansi@6.2.0: - resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} - engines: {node: '>=8'} - - wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} - - y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - - yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - - yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} - - yoctocolors-cjs@2.1.3: - resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==} - engines: {node: '>=18'} - -snapshots: - - '@biomejs/biome@2.3.1': - optionalDependencies: - '@biomejs/cli-darwin-arm64': 2.3.1 - '@biomejs/cli-darwin-x64': 2.3.1 - '@biomejs/cli-linux-arm64': 2.3.1 - '@biomejs/cli-linux-arm64-musl': 2.3.1 - '@biomejs/cli-linux-x64': 2.3.1 - '@biomejs/cli-linux-x64-musl': 2.3.1 - '@biomejs/cli-win32-arm64': 2.3.1 - '@biomejs/cli-win32-x64': 2.3.1 - - '@biomejs/cli-darwin-arm64@2.3.1': - optional: true - - '@biomejs/cli-darwin-x64@2.3.1': - optional: true - - '@biomejs/cli-linux-arm64-musl@2.3.1': - optional: true - - '@biomejs/cli-linux-arm64@2.3.1': - optional: true - - '@biomejs/cli-linux-x64-musl@2.3.1': - optional: true - - '@biomejs/cli-linux-x64@2.3.1': - optional: true - - '@biomejs/cli-win32-arm64@2.3.1': - optional: true - - '@biomejs/cli-win32-x64@2.3.1': - optional: true - - '@bundled-es-modules/cookie@2.0.1': - dependencies: - cookie: 0.7.2 - - '@bundled-es-modules/statuses@1.0.1': - dependencies: - statuses: 2.0.2 - - '@esbuild/aix-ppc64@0.25.12': - optional: true - - '@esbuild/android-arm64@0.25.12': - optional: true - - '@esbuild/android-arm@0.25.12': - optional: true - - '@esbuild/android-x64@0.25.12': - optional: true - - '@esbuild/darwin-arm64@0.25.12': - optional: true - - '@esbuild/darwin-x64@0.25.12': - optional: true - - '@esbuild/freebsd-arm64@0.25.12': - optional: true - - '@esbuild/freebsd-x64@0.25.12': - optional: true - - '@esbuild/linux-arm64@0.25.12': - optional: true - - '@esbuild/linux-arm@0.25.12': - optional: true - - '@esbuild/linux-ia32@0.25.12': - optional: true - - '@esbuild/linux-loong64@0.25.12': - optional: true - - '@esbuild/linux-mips64el@0.25.12': - optional: true - - '@esbuild/linux-ppc64@0.25.12': - optional: true - - '@esbuild/linux-riscv64@0.25.12': - optional: true - - '@esbuild/linux-s390x@0.25.12': - optional: true - - '@esbuild/linux-x64@0.25.12': - optional: true - - '@esbuild/netbsd-arm64@0.25.12': - optional: true - - '@esbuild/netbsd-x64@0.25.12': - optional: true - - '@esbuild/openbsd-arm64@0.25.12': - optional: true - - '@esbuild/openbsd-x64@0.25.12': - optional: true - - '@esbuild/openharmony-arm64@0.25.12': - optional: true - - '@esbuild/sunos-x64@0.25.12': - optional: true - - '@esbuild/win32-arm64@0.25.12': - optional: true - - '@esbuild/win32-ia32@0.25.12': - optional: true - - '@esbuild/win32-x64@0.25.12': - optional: true - - '@inquirer/ansi@1.0.2': {} - - '@inquirer/confirm@5.1.21(@types/node@18.19.130)': - dependencies: - '@inquirer/core': 10.3.2(@types/node@18.19.130) - '@inquirer/type': 3.0.10(@types/node@18.19.130) - optionalDependencies: - '@types/node': 18.19.130 - - '@inquirer/core@10.3.2(@types/node@18.19.130)': - dependencies: - '@inquirer/ansi': 1.0.2 - '@inquirer/figures': 1.0.15 - '@inquirer/type': 3.0.10(@types/node@18.19.130) - cli-width: 4.1.0 - mute-stream: 2.0.0 - signal-exit: 4.1.0 - wrap-ansi: 6.2.0 - yoctocolors-cjs: 2.1.3 - optionalDependencies: - '@types/node': 18.19.130 - - '@inquirer/figures@1.0.15': {} - - '@inquirer/type@3.0.10(@types/node@18.19.130)': - optionalDependencies: - '@types/node': 18.19.130 - - '@jridgewell/gen-mapping@0.3.13': - dependencies: - '@jridgewell/sourcemap-codec': 1.5.5 - '@jridgewell/trace-mapping': 0.3.31 - - '@jridgewell/resolve-uri@3.1.2': {} - - '@jridgewell/source-map@0.3.11': - dependencies: - '@jridgewell/gen-mapping': 0.3.13 - '@jridgewell/trace-mapping': 0.3.31 - - '@jridgewell/sourcemap-codec@1.5.5': {} - - '@jridgewell/trace-mapping@0.3.31': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.5 - - '@mswjs/interceptors@0.39.8': - dependencies: - '@open-draft/deferred-promise': 2.2.0 - '@open-draft/logger': 0.3.0 - '@open-draft/until': 2.1.0 - is-node-process: 1.2.0 - outvariant: 1.4.3 - strict-event-emitter: 0.5.1 - - '@open-draft/deferred-promise@2.2.0': {} - - '@open-draft/logger@0.3.0': - dependencies: - is-node-process: 1.2.0 - outvariant: 1.4.3 - - '@open-draft/until@2.1.0': {} - - '@rollup/rollup-android-arm-eabi@4.53.3': - optional: true - - '@rollup/rollup-android-arm64@4.53.3': - optional: true - - '@rollup/rollup-darwin-arm64@4.53.3': - optional: true - - '@rollup/rollup-darwin-x64@4.53.3': - optional: true - - '@rollup/rollup-freebsd-arm64@4.53.3': - optional: true - - '@rollup/rollup-freebsd-x64@4.53.3': - optional: true - - '@rollup/rollup-linux-arm-gnueabihf@4.53.3': - optional: true - - '@rollup/rollup-linux-arm-musleabihf@4.53.3': - optional: true - - '@rollup/rollup-linux-arm64-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-arm64-musl@4.53.3': - optional: true - - '@rollup/rollup-linux-loong64-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-ppc64-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-riscv64-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-riscv64-musl@4.53.3': - optional: true - - '@rollup/rollup-linux-s390x-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-x64-gnu@4.53.3': - optional: true - - '@rollup/rollup-linux-x64-musl@4.53.3': - optional: true - - '@rollup/rollup-openharmony-arm64@4.53.3': - optional: true - - '@rollup/rollup-win32-arm64-msvc@4.53.3': - optional: true - - '@rollup/rollup-win32-ia32-msvc@4.53.3': - optional: true - - '@rollup/rollup-win32-x64-gnu@4.53.3': - optional: true - - '@rollup/rollup-win32-x64-msvc@4.53.3': - optional: true - - '@types/chai@5.2.3': - dependencies: - '@types/deep-eql': 4.0.2 - assertion-error: 2.0.1 - - '@types/cookie@0.6.0': {} - - '@types/deep-eql@4.0.2': {} - - '@types/eslint-scope@3.7.7': - dependencies: - '@types/eslint': 9.6.1 - '@types/estree': 1.0.8 - - '@types/eslint@9.6.1': - dependencies: - '@types/estree': 1.0.8 - '@types/json-schema': 7.0.15 - - '@types/estree@1.0.8': {} - - '@types/json-schema@7.0.15': {} - - '@types/node@18.19.130': - dependencies: - undici-types: 5.26.5 - - '@types/statuses@2.0.6': {} - - '@vitest/expect@3.2.4': - dependencies: - '@types/chai': 5.2.3 - '@vitest/spy': 3.2.4 - '@vitest/utils': 3.2.4 - chai: 5.3.3 - tinyrainbow: 2.0.0 - - '@vitest/mocker@3.2.4(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0))': - dependencies: - '@vitest/spy': 3.2.4 - estree-walker: 3.0.3 - magic-string: 0.30.21 - optionalDependencies: - msw: 2.11.2(@types/node@18.19.130)(typescript@5.7.3) - vite: 7.2.6(@types/node@18.19.130)(terser@5.46.0) - - '@vitest/pretty-format@3.2.4': - dependencies: - tinyrainbow: 2.0.0 - - '@vitest/runner@3.2.4': - dependencies: - '@vitest/utils': 3.2.4 - pathe: 2.0.3 - strip-literal: 3.1.0 - - '@vitest/snapshot@3.2.4': - dependencies: - '@vitest/pretty-format': 3.2.4 - magic-string: 0.30.21 - pathe: 2.0.3 - - '@vitest/spy@3.2.4': - dependencies: - tinyspy: 4.0.4 - - '@vitest/utils@3.2.4': - dependencies: - '@vitest/pretty-format': 3.2.4 - loupe: 3.2.1 - tinyrainbow: 2.0.0 - - '@webassemblyjs/ast@1.14.1': - dependencies: - '@webassemblyjs/helper-numbers': 1.13.2 - '@webassemblyjs/helper-wasm-bytecode': 1.13.2 - - '@webassemblyjs/floating-point-hex-parser@1.13.2': {} - - '@webassemblyjs/helper-api-error@1.13.2': {} - - '@webassemblyjs/helper-buffer@1.14.1': {} - - '@webassemblyjs/helper-numbers@1.13.2': - dependencies: - '@webassemblyjs/floating-point-hex-parser': 1.13.2 - '@webassemblyjs/helper-api-error': 1.13.2 - '@xtuc/long': 4.2.2 - - '@webassemblyjs/helper-wasm-bytecode@1.13.2': {} - - '@webassemblyjs/helper-wasm-section@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/helper-buffer': 1.14.1 - '@webassemblyjs/helper-wasm-bytecode': 1.13.2 - '@webassemblyjs/wasm-gen': 1.14.1 - - '@webassemblyjs/ieee754@1.13.2': - dependencies: - '@xtuc/ieee754': 1.2.0 - - '@webassemblyjs/leb128@1.13.2': - dependencies: - '@xtuc/long': 4.2.2 - - '@webassemblyjs/utf8@1.13.2': {} - - '@webassemblyjs/wasm-edit@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/helper-buffer': 1.14.1 - '@webassemblyjs/helper-wasm-bytecode': 1.13.2 - '@webassemblyjs/helper-wasm-section': 1.14.1 - '@webassemblyjs/wasm-gen': 1.14.1 - '@webassemblyjs/wasm-opt': 1.14.1 - '@webassemblyjs/wasm-parser': 1.14.1 - '@webassemblyjs/wast-printer': 1.14.1 - - '@webassemblyjs/wasm-gen@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/helper-wasm-bytecode': 1.13.2 - '@webassemblyjs/ieee754': 1.13.2 - '@webassemblyjs/leb128': 1.13.2 - '@webassemblyjs/utf8': 1.13.2 - - '@webassemblyjs/wasm-opt@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/helper-buffer': 1.14.1 - '@webassemblyjs/wasm-gen': 1.14.1 - '@webassemblyjs/wasm-parser': 1.14.1 - - '@webassemblyjs/wasm-parser@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/helper-api-error': 1.13.2 - '@webassemblyjs/helper-wasm-bytecode': 1.13.2 - '@webassemblyjs/ieee754': 1.13.2 - '@webassemblyjs/leb128': 1.13.2 - '@webassemblyjs/utf8': 1.13.2 - - '@webassemblyjs/wast-printer@1.14.1': - dependencies: - '@webassemblyjs/ast': 1.14.1 - '@xtuc/long': 4.2.2 - - '@xtuc/ieee754@1.2.0': {} - - '@xtuc/long@4.2.2': {} - - acorn-import-phases@1.0.4(acorn@8.15.0): - dependencies: - acorn: 8.15.0 - - acorn@8.15.0: {} - - ajv-formats@2.1.1(ajv@8.17.1): - optionalDependencies: - ajv: 8.17.1 - - ajv-keywords@5.1.0(ajv@8.17.1): - dependencies: - ajv: 8.17.1 - fast-deep-equal: 3.1.3 - - ajv@8.17.1: - dependencies: - fast-deep-equal: 3.1.3 - fast-uri: 3.1.0 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - - ansi-regex@5.0.1: {} - - ansi-styles@4.3.0: - dependencies: - color-convert: 2.0.1 - - assertion-error@2.0.1: {} - - baseline-browser-mapping@2.9.19: {} - - braces@3.0.3: - dependencies: - fill-range: 7.1.1 - - browserslist@4.28.1: - dependencies: - baseline-browser-mapping: 2.9.19 - caniuse-lite: 1.0.30001769 - electron-to-chromium: 1.5.286 - node-releases: 2.0.27 - update-browserslist-db: 1.2.3(browserslist@4.28.1) - - buffer-from@1.1.2: {} - - cac@6.7.14: {} - - caniuse-lite@1.0.30001769: {} - - chai@5.3.3: - dependencies: - assertion-error: 2.0.1 - check-error: 2.1.1 - deep-eql: 5.0.2 - loupe: 3.2.1 - pathval: 2.0.1 - - chalk@4.1.2: - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - - check-error@2.1.1: {} - - chrome-trace-event@1.0.4: {} - - cli-width@4.1.0: {} - - cliui@8.0.1: - dependencies: - string-width: 4.2.3 - strip-ansi: 6.0.1 - wrap-ansi: 7.0.0 - - color-convert@2.0.1: - dependencies: - color-name: 1.1.4 - - color-name@1.1.4: {} - - commander@2.20.3: {} - - cookie@0.7.2: {} - - debug@4.4.3: - dependencies: - ms: 2.1.3 - - deep-eql@5.0.2: {} - - electron-to-chromium@1.5.286: {} - - emoji-regex@8.0.0: {} - - enhanced-resolve@5.18.3: - dependencies: - graceful-fs: 4.2.11 - tapable: 2.3.0 - - enhanced-resolve@5.19.0: - dependencies: - graceful-fs: 4.2.11 - tapable: 2.3.0 - - es-module-lexer@1.7.0: {} - - es-module-lexer@2.0.0: {} - - esbuild@0.25.12: - optionalDependencies: - '@esbuild/aix-ppc64': 0.25.12 - '@esbuild/android-arm': 0.25.12 - '@esbuild/android-arm64': 0.25.12 - '@esbuild/android-x64': 0.25.12 - '@esbuild/darwin-arm64': 0.25.12 - '@esbuild/darwin-x64': 0.25.12 - '@esbuild/freebsd-arm64': 0.25.12 - '@esbuild/freebsd-x64': 0.25.12 - '@esbuild/linux-arm': 0.25.12 - '@esbuild/linux-arm64': 0.25.12 - '@esbuild/linux-ia32': 0.25.12 - '@esbuild/linux-loong64': 0.25.12 - '@esbuild/linux-mips64el': 0.25.12 - '@esbuild/linux-ppc64': 0.25.12 - '@esbuild/linux-riscv64': 0.25.12 - '@esbuild/linux-s390x': 0.25.12 - '@esbuild/linux-x64': 0.25.12 - '@esbuild/netbsd-arm64': 0.25.12 - '@esbuild/netbsd-x64': 0.25.12 - '@esbuild/openbsd-arm64': 0.25.12 - '@esbuild/openbsd-x64': 0.25.12 - '@esbuild/openharmony-arm64': 0.25.12 - '@esbuild/sunos-x64': 0.25.12 - '@esbuild/win32-arm64': 0.25.12 - '@esbuild/win32-ia32': 0.25.12 - '@esbuild/win32-x64': 0.25.12 - - escalade@3.2.0: {} - - eslint-scope@5.1.1: - dependencies: - esrecurse: 4.3.0 - estraverse: 4.3.0 - - esrecurse@4.3.0: - dependencies: - estraverse: 5.3.0 - - estraverse@4.3.0: {} - - estraverse@5.3.0: {} - - estree-walker@3.0.3: - dependencies: - '@types/estree': 1.0.8 - - events@3.3.0: {} - - expect-type@1.2.2: {} - - fast-deep-equal@3.1.3: {} - - fast-uri@3.1.0: {} - - fdir@6.5.0(picomatch@4.0.3): - optionalDependencies: - picomatch: 4.0.3 - - fill-range@7.1.1: - dependencies: - to-regex-range: 5.0.1 - - fsevents@2.3.3: - optional: true - - get-caller-file@2.0.5: {} - - glob-to-regexp@0.4.1: {} - - graceful-fs@4.2.11: {} - - graphql@16.12.0: {} - - has-flag@4.0.0: {} - - headers-polyfill@4.0.3: {} - - is-fullwidth-code-point@3.0.0: {} - - is-node-process@1.2.0: {} - - is-number@7.0.0: {} - - jest-worker@27.5.1: - dependencies: - '@types/node': 18.19.130 - merge-stream: 2.0.0 - supports-color: 8.1.1 - - js-tokens@9.0.1: {} - - json-parse-even-better-errors@2.3.1: {} - - json-schema-traverse@1.0.0: {} - - loader-runner@4.3.1: {} - - loupe@3.2.1: {} - - magic-string@0.30.21: - dependencies: - '@jridgewell/sourcemap-codec': 1.5.5 - - merge-stream@2.0.0: {} - - micromatch@4.0.8: - dependencies: - braces: 3.0.3 - picomatch: 2.3.1 - - mime-db@1.52.0: {} - - mime-types@2.1.35: - dependencies: - mime-db: 1.52.0 - - ms@2.1.3: {} - - msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3): - dependencies: - '@bundled-es-modules/cookie': 2.0.1 - '@bundled-es-modules/statuses': 1.0.1 - '@inquirer/confirm': 5.1.21(@types/node@18.19.130) - '@mswjs/interceptors': 0.39.8 - '@open-draft/deferred-promise': 2.2.0 - '@open-draft/until': 2.1.0 - '@types/cookie': 0.6.0 - '@types/statuses': 2.0.6 - graphql: 16.12.0 - headers-polyfill: 4.0.3 - is-node-process: 1.2.0 - outvariant: 1.4.3 - path-to-regexp: 6.3.0 - picocolors: 1.1.1 - rettime: 0.7.0 - strict-event-emitter: 0.5.1 - tough-cookie: 6.0.0 - type-fest: 4.41.0 - yargs: 17.7.2 - optionalDependencies: - typescript: 5.7.3 - transitivePeerDependencies: - - '@types/node' - - mute-stream@2.0.0: {} - - nanoid@3.3.11: {} - - neo-async@2.6.2: {} - - node-releases@2.0.27: {} - - outvariant@1.4.3: {} - - path-to-regexp@6.3.0: {} - - pathe@2.0.3: {} - - pathval@2.0.1: {} - - picocolors@1.1.1: {} - - picomatch@2.3.1: {} - - picomatch@4.0.3: {} - - postcss@8.5.6: - dependencies: - nanoid: 3.3.11 - picocolors: 1.1.1 - source-map-js: 1.2.1 - - randombytes@2.1.0: - dependencies: - safe-buffer: 5.2.1 - - require-directory@2.1.1: {} - - require-from-string@2.0.2: {} - - rettime@0.7.0: {} - - rollup@4.53.3: - dependencies: - '@types/estree': 1.0.8 - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.53.3 - '@rollup/rollup-android-arm64': 4.53.3 - '@rollup/rollup-darwin-arm64': 4.53.3 - '@rollup/rollup-darwin-x64': 4.53.3 - '@rollup/rollup-freebsd-arm64': 4.53.3 - '@rollup/rollup-freebsd-x64': 4.53.3 - '@rollup/rollup-linux-arm-gnueabihf': 4.53.3 - '@rollup/rollup-linux-arm-musleabihf': 4.53.3 - '@rollup/rollup-linux-arm64-gnu': 4.53.3 - '@rollup/rollup-linux-arm64-musl': 4.53.3 - '@rollup/rollup-linux-loong64-gnu': 4.53.3 - '@rollup/rollup-linux-ppc64-gnu': 4.53.3 - '@rollup/rollup-linux-riscv64-gnu': 4.53.3 - '@rollup/rollup-linux-riscv64-musl': 4.53.3 - '@rollup/rollup-linux-s390x-gnu': 4.53.3 - '@rollup/rollup-linux-x64-gnu': 4.53.3 - '@rollup/rollup-linux-x64-musl': 4.53.3 - '@rollup/rollup-openharmony-arm64': 4.53.3 - '@rollup/rollup-win32-arm64-msvc': 4.53.3 - '@rollup/rollup-win32-ia32-msvc': 4.53.3 - '@rollup/rollup-win32-x64-gnu': 4.53.3 - '@rollup/rollup-win32-x64-msvc': 4.53.3 - fsevents: 2.3.3 - - safe-buffer@5.2.1: {} - - schema-utils@4.3.3: - dependencies: - '@types/json-schema': 7.0.15 - ajv: 8.17.1 - ajv-formats: 2.1.1(ajv@8.17.1) - ajv-keywords: 5.1.0(ajv@8.17.1) - - semver@7.7.3: {} - - serialize-javascript@6.0.2: - dependencies: - randombytes: 2.1.0 - - siginfo@2.0.0: {} - - signal-exit@4.1.0: {} - - source-map-js@1.2.1: {} - - source-map-support@0.5.21: - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - - source-map@0.6.1: {} - - source-map@0.7.6: {} - - stackback@0.0.2: {} - - statuses@2.0.2: {} - - std-env@3.10.0: {} - - strict-event-emitter@0.5.1: {} - - string-width@4.2.3: - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - - strip-ansi@6.0.1: - dependencies: - ansi-regex: 5.0.1 - - strip-literal@3.1.0: - dependencies: - js-tokens: 9.0.1 - - supports-color@7.2.0: - dependencies: - has-flag: 4.0.0 - - supports-color@8.1.1: - dependencies: - has-flag: 4.0.0 - - tapable@2.3.0: {} - - terser-webpack-plugin@5.3.16(webpack@5.104.1): - dependencies: - '@jridgewell/trace-mapping': 0.3.31 - jest-worker: 27.5.1 - schema-utils: 4.3.3 - serialize-javascript: 6.0.2 - terser: 5.46.0 - webpack: 5.104.1 - - terser@5.46.0: - dependencies: - '@jridgewell/source-map': 0.3.11 - acorn: 8.15.0 - commander: 2.20.3 - source-map-support: 0.5.21 - - tinybench@2.9.0: {} - - tinyexec@0.3.2: {} - - tinyglobby@0.2.15: - dependencies: - fdir: 6.5.0(picomatch@4.0.3) - picomatch: 4.0.3 - - tinypool@1.1.1: {} - - tinyrainbow@2.0.0: {} - - tinyspy@4.0.4: {} - - tldts-core@7.0.19: {} - - tldts@7.0.19: - dependencies: - tldts-core: 7.0.19 - - to-regex-range@5.0.1: - dependencies: - is-number: 7.0.0 - - tough-cookie@6.0.0: - dependencies: - tldts: 7.0.19 - - ts-loader@9.5.4(typescript@5.7.3)(webpack@5.104.1): - dependencies: - chalk: 4.1.2 - enhanced-resolve: 5.18.3 - micromatch: 4.0.8 - semver: 7.7.3 - source-map: 0.7.6 - typescript: 5.7.3 - webpack: 5.104.1 - - type-fest@4.41.0: {} - - typescript@5.7.3: {} - - undici-types@5.26.5: {} - - update-browserslist-db@1.2.3(browserslist@4.28.1): - dependencies: - browserslist: 4.28.1 - escalade: 3.2.0 - picocolors: 1.1.1 - - vite-node@3.2.4(@types/node@18.19.130)(terser@5.46.0): - dependencies: - cac: 6.7.14 - debug: 4.4.3 - es-module-lexer: 1.7.0 - pathe: 2.0.3 - vite: 7.2.6(@types/node@18.19.130)(terser@5.46.0) - transitivePeerDependencies: - - '@types/node' - - jiti - - less - - lightningcss - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - tsx - - yaml - - vite@7.2.6(@types/node@18.19.130)(terser@5.46.0): - dependencies: - esbuild: 0.25.12 - fdir: 6.5.0(picomatch@4.0.3) - picomatch: 4.0.3 - postcss: 8.5.6 - rollup: 4.53.3 - tinyglobby: 0.2.15 - optionalDependencies: - '@types/node': 18.19.130 - fsevents: 2.3.3 - terser: 5.46.0 - - vitest@3.2.4(@types/node@18.19.130)(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(terser@5.46.0): - dependencies: - '@types/chai': 5.2.3 - '@vitest/expect': 3.2.4 - '@vitest/mocker': 3.2.4(msw@2.11.2(@types/node@18.19.130)(typescript@5.7.3))(vite@7.2.6(@types/node@18.19.130)(terser@5.46.0)) - '@vitest/pretty-format': 3.2.4 - '@vitest/runner': 3.2.4 - '@vitest/snapshot': 3.2.4 - '@vitest/spy': 3.2.4 - '@vitest/utils': 3.2.4 - chai: 5.3.3 - debug: 4.4.3 - expect-type: 1.2.2 - magic-string: 0.30.21 - pathe: 2.0.3 - picomatch: 4.0.3 - std-env: 3.10.0 - tinybench: 2.9.0 - tinyexec: 0.3.2 - tinyglobby: 0.2.15 - tinypool: 1.1.1 - tinyrainbow: 2.0.0 - vite: 7.2.6(@types/node@18.19.130)(terser@5.46.0) - vite-node: 3.2.4(@types/node@18.19.130)(terser@5.46.0) - why-is-node-running: 2.3.0 - optionalDependencies: - '@types/node': 18.19.130 - transitivePeerDependencies: - - jiti - - less - - lightningcss - - msw - - sass - - sass-embedded - - stylus - - sugarss - - supports-color - - terser - - tsx - - yaml - - watchpack@2.5.1: - dependencies: - glob-to-regexp: 0.4.1 - graceful-fs: 4.2.11 - - webpack-sources@3.3.3: {} - - webpack@5.104.1: - dependencies: - '@types/eslint-scope': 3.7.7 - '@types/estree': 1.0.8 - '@types/json-schema': 7.0.15 - '@webassemblyjs/ast': 1.14.1 - '@webassemblyjs/wasm-edit': 1.14.1 - '@webassemblyjs/wasm-parser': 1.14.1 - acorn: 8.15.0 - acorn-import-phases: 1.0.4(acorn@8.15.0) - browserslist: 4.28.1 - chrome-trace-event: 1.0.4 - enhanced-resolve: 5.19.0 - es-module-lexer: 2.0.0 - eslint-scope: 5.1.1 - events: 3.3.0 - glob-to-regexp: 0.4.1 - graceful-fs: 4.2.11 - json-parse-even-better-errors: 2.3.1 - loader-runner: 4.3.1 - mime-types: 2.1.35 - neo-async: 2.6.2 - schema-utils: 4.3.3 - tapable: 2.3.0 - terser-webpack-plugin: 5.3.16(webpack@5.104.1) - watchpack: 2.5.1 - webpack-sources: 3.3.3 - transitivePeerDependencies: - - '@swc/core' - - esbuild - - uglify-js - - why-is-node-running@2.3.0: - dependencies: - siginfo: 2.0.0 - stackback: 0.0.2 - - wrap-ansi@6.2.0: - dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - - wrap-ansi@7.0.0: - dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - - y18n@5.0.8: {} - - yargs-parser@21.1.1: {} - - yargs@17.7.2: - dependencies: - cliui: 8.0.1 - escalade: 3.2.0 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 21.1.1 - - yoctocolors-cjs@2.1.3: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml deleted file mode 100644 index 6e4c3951..00000000 --- a/pnpm-workspace.yaml +++ /dev/null @@ -1 +0,0 @@ -packages: ['.'] \ No newline at end of file diff --git a/reference.md b/reference.md deleted file mode 100644 index 224ae271..00000000 --- a/reference.md +++ /dev/null @@ -1,21544 +0,0 @@ -# Reference -## Admins -
client.admins.identify() -> 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.admins.identify(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `AdminsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.admins.away({ ...params }) -> Intercom.Admin | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can set an Admin as away for the Inbox. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ConfigureAwayAdminRequest` - -
-
- -
-
- -**requestOptions:** `AdminsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.admins.listAllActivityLogs({ ...params }) -> Intercom.ActivityLogList -
-
- -#### 📝 Description - -
-
- -
-
- -You can get a log of activities by all admins in an app. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.admins.listAllActivityLogs({ - created_at_after: "1677253093", - created_at_before: "1677861493" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListAllActivityLogsRequest` - -
-
- -
-
- -**requestOptions:** `AdminsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.admins.list() -> Intercom.AdminList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of admins for a given workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.admins.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `AdminsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.admins.find({ ...params }) -> Intercom.Admin | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can retrieve the details of a single admin. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.admins.find({ - admin_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindAdminRequest` - -
-
- -
-
- -**requestOptions:** `AdminsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## AI Content -
client.aiContent.listContentImportSources() -> Intercom.ContentImportSourcesList -
-
- -#### 📝 Description - -
-
- -
-
- -You can retrieve a list of all content import sources for a workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.aiContent.listContentImportSources(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.aiContent.createContentImportSource({ - url: "https://www.example.com" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateContentImportSourceRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.aiContent.getContentImportSource({ ...params }) -> Intercom.ContentImportSource -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.aiContent.getContentImportSource({ - source_id: "source_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.GetContentImportSourceRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.aiContent.updateContentImportSource({ ...params }) -> Intercom.ContentImportSource -
-
- -#### 📝 Description - -
-
- -
-
- -You can update an existing content import source. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.aiContent.updateContentImportSource({ - source_id: "source_id", - sync_behavior: "api", - url: "https://www.example.com" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateContentImportSourceRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.aiContent.deleteContentImportSource({ - source_id: "source_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteContentImportSourceRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.aiContent.listExternalPages() -> Intercom.ExternalPagesList -
-
- -#### 📝 Description - -
-
- -
-
- -You can retrieve a list of all external pages for a workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.aiContent.listExternalPages(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.aiContent.createExternalPage({ - title: "Test", - html: "

Test

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

Test

", - url: "https://www.example.com", - source_id: 47, - external_id: "5678" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateExternalPageRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.aiContent.deleteExternalPage({ - page_id: "page_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteExternalPageRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Articles -
client.articles.list({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.articles.list(); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.articles.list(); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListArticlesRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.articles.create({ ...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.articles.create({ - title: "Thanks for everything", - description: "Description of the Article", - body: "Body of the Article", - author_id: 991267497, - state: "published", - parent_id: 145, - parent_type: "collection", - translated_content: { - fr: { - title: "Merci pour tout", - description: "Description de l'article", - body: "Corps de l'article", - author_id: 991267497, - state: "published" - } - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateArticleRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.articles.find({ ...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.articles.find({ - article_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindArticleRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.articles.update({ ...params }) -> Intercom.Article -
-
- -#### 📝 Description - -
-
- -
-
- -You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.articles.update({ - article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateArticleRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.articles.delete({ ...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.articles.delete({ - article_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteArticleRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.articles.search({ ...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.articles.search({ - phrase: "Getting started", - state: "published", - help_center_id: 1, - highlight: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.SearchArticlesRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Away Status Reasons -
client.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReason[] -
-
- -#### 📝 Description - -
-
- -
-
- -Returns a list of all away status reasons configured for the workspace, including deleted ones. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.awayStatusReasons.listAwayStatusReasons(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `AwayStatusReasonsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Export -
client.export.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.export.enqueueANewReportingDataExportJob({ - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.PostExportReportingDataEnqueueRequest` - -
-
- -
-
- -**requestOptions:** `ExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.export.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.export.listAvailableDatasetsAndAttributes(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `ExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Data Export -
client.dataExport.exportReportingData({ ...params }) -> Intercom.DataExportExportReportingDataResponse -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.dataExport.exportReportingData({ - job_identifier: "job_identifier", - app_id: "app_id", - client_id: "client_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ExportReportingDataRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataExport.downloadReportingDataExport({ ...params }) -> void -
-
- -#### 📝 Description - -
-
- -
-
- -Download the data from a completed reporting data export job. - -> Octet header required -> -> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.dataExport.downloadReportingDataExport({ - job_identifier: "job_identifier", - app_id: "app_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DownloadReportingDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataExport.create({ ...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.dataExport.create({ - created_at_after: 1734519776, - created_at_before: 1734537776 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataExport.find({ ...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.dataExport.find({ - job_identifier: "job_identifier" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataExport.cancel({ ...params }) -> Intercom.DataExport -
-
- -#### 📝 Description - -
-
- -
-
- -You can cancel your job -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.dataExport.cancel({ - job_identifier: "job_identifier" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CancelDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataExport.download({ ...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.dataExport.download({ - job_identifier: "job_identifier" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DownloadDataExportRequest` - -
-
- -
-
- -**requestOptions:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## HelpCenters -
client.helpCenters.find({ ...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.helpCenters.find({ - help_center_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindHelpCenterRequest` - -
-
- -
-
- -**requestOptions:** `HelpCentersClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.helpCenters.list({ ...params }) -> core.Page -
-
- -#### 📝 Description - -
-
- -
-
- -You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -const pageableResponse = await client.helpCenters.list(); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.helpCenters.list(); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListHelpCentersRequest` - -
-
- -
-
- -**requestOptions:** `HelpCentersClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Internal Articles -
client.internalArticles.listInternalArticles() -> Intercom.InternalArticleList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.listInternalArticles(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.internalArticles.createInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.internalArticles.retrieveInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.retrieveInternalArticle({ - internal_article_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.RetrieveInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.internalArticles.updateInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.updateInternalArticle({ - internal_article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateInternalArticleRequestBody` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.internalArticles.deleteInternalArticle({ ...params }) -> Intercom.DeletedInternalArticleObject -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.deleteInternalArticle({ - internal_article_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.internalArticles.searchInternalArticles({ ...params }) -> Intercom.InternalArticleSearchResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.internalArticles.searchInternalArticles({ - folder_id: "folder_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.SearchInternalArticlesRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## IP Allowlist -
client.ipAllowlist.getIpAllowlist() -> Intercom.IpAllowlist -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve the current IP allowlist configuration for the workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ipAllowlist.getIpAllowlist(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `IpAllowlistClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.ipAllowlist.updateIpAllowlist({ ...params }) -> Intercom.IpAllowlist -
-
- -#### 📝 Description - -
-
- -
-
- -Update the IP allowlist configuration for the workspace. - -{% admonition type="warning" name="Lockout Protection" %} - The API will reject updates that would lock out the caller's IP address. Ensure your current IP is included in the allowlist when enabling the feature. -{% /admonition %} -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ipAllowlist.updateIpAllowlist({ - enabled: true, - ip_allowlist: ["192.168.1.0/24", "10.0.0.1"] -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.IpAllowlist` - -
-
- -
-
- -**requestOptions:** `IpAllowlistClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Companies -
client.companies.retrieve({ ...params }) -> Intercom.CompaniesRetrieveResponse -
-
- -#### 📝 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.companies.retrieve({ - name: "my company", - company_id: "12345", - tag_id: "678910", - segment_id: "98765", - page: 1, - per_page: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.RetrieveCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.createOrUpdate({ ...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.companies.createOrUpdate({ - name: "my company", - company_id: "company_remote_id", - remote_created_at: 1374138000 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateOrUpdateCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.find({ ...params }) -> Intercom.Company -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a single company. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.find({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.update({ ...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.companies.update({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - body: { - name: "my company", - website: "http://www.mycompany.com/" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.delete({ ...params }) -> Intercom.DeletedCompanyObject -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single company. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.delete({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.listAttachedContacts({ ...params }) -> Intercom.CompanyAttachedContacts -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all contacts that belong to a company. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.listAttachedContacts({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListAttachedContactsRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.listAttachedSegments({ ...params }) -> Intercom.CompanyAttachedSegments -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all segments that belong to a company. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.listAttachedSegments({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListSegmentsAttachedToCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.list({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.companies.list({ - page: 1, - per_page: 1, - order: "desc" -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.companies.list({ - page: 1, - per_page: 1, - order: "desc" -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.scroll({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.companies.scroll({ - scroll_param: "scroll_param" -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.companies.scroll({ - scroll_param: "scroll_param" -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ScrollCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.attachContact({ ...params }) -> Intercom.Company -
-
- -#### 📝 Description - -
-
- -
-
- -You can attach a company to a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.attachContact({ - contact_id: "contact_id", - id: "6762f09a1bb69f9f2193bb34" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.AttachContactToCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.companies.detachContact({ ...params }) -> Intercom.Company -
-
- -#### 📝 Description - -
-
- -
-
- -You can detach a company from a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.companies.detachContact({ - contact_id: "58a430d35458202d41b1e65b", - company_id: "58a430d35458202d41b1e65b" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DetachContactFromCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Contacts -
client.contacts.listAttachedCompanies({ ...params }) -> core.Page -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of companies that are associated to a contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -const pageableResponse = await client.contacts.listAttachedCompanies({ - contact_id: "63a07ddf05a32042dffac965", - page: 1, - per_page: 1 -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.contacts.listAttachedCompanies({ - contact_id: "63a07ddf05a32042dffac965", - page: 1, - per_page: 1 -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListAttachedCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.listAttachedSegments({ ...params }) -> Intercom.ContactSegments -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of segments that are associated to a contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.listAttachedSegments({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListSegmentsAttachedToContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.listAttachedSubscriptions({ ...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.contacts.listAttachedSubscriptions({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListAttachedSubscriptionsRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.attachSubscription({ ...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.contacts.attachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.AttachSubscriptionToContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.detachSubscription({ ...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.contacts.detachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - subscription_id: "37846" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DetachSubscriptionFromContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.listAttachedTags({ ...params }) -> Intercom.TagList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all tags that are attached to a specific contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.listAttachedTags({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListTagsAttachedToContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.find({ ...params }) -> Intercom.ContactsFindResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.find({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.update({ ...params }) -> Intercom.ContactsUpdateResponse -
-
- -#### 📝 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.contacts.update({ - contact_id: "63a07ddf05a32042dffac965", - email: "joebloggs@intercom.io", - name: "joe bloggs" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.delete({ ...params }) -> Intercom.ContactDeleted -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.delete({ - contact_id: "contact_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.mergeLeadInUser({ ...params }) -> Intercom.ContactsMergeLeadInUserResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.mergeLeadInUser({ - from: "6762f0d51bb69f9f2193bb7f", - into: "6762f0d51bb69f9f2193bb80" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.MergeContactsRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.search({ ...params }) -> core.Page -
-
- -#### 📝 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 | -| 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 -const pageableResponse = await client.contacts.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.contacts.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.SearchRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.list({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.contacts.list(); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.contacts.list(); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListContactsRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.create({ ...params }) -> Intercom.ContactsCreateResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a new contact (ie. user or lead). -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.create({ - email: "joebloggs@intercom.io" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.contacts.showContactByExternalId({ - external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ShowContactByExternalIdRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.archive({ ...params }) -> Intercom.ContactArchived -
-
- -#### 📝 Description - -
-
- -
-
- -You can archive a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.archive({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ArchiveContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.contacts.unarchive({ ...params }) -> Intercom.ContactUnarchived -
-
- -#### 📝 Description - -
-
- -
-
- -You can unarchive a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.contacts.unarchive({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UnarchiveContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.contacts.blockContact({ - contact_id: "63a07ddf05a32042dffac965" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.BlockContactRequest` - -
-
- -
-
- -**requestOptions:** `ContactsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Notes -
client.notes.list({ ...params }) -> core.Page -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of notes that are associated to a contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -const pageableResponse = await client.notes.list({ - contact_id: "contact_id" -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.notes.list({ - contact_id: "contact_id" -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListContactNotesRequest` - -
-
- -
-
- -**requestOptions:** `NotesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.notes.create({ ...params }) -> Intercom.Note -
-
- -#### 📝 Description - -
-
- -
-
- -You can add a note to a single contact. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.notes.create({ - contact_id: "123", - body: "Hello", - admin_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateContactNoteRequest` - -
-
- -
-
- -**requestOptions:** `NotesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.notes.find({ ...params }) -> Intercom.Note -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single note. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.notes.find({ - note_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindNoteRequest` - -
-
- -
-
- -**requestOptions:** `NotesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Tags -
client.tags.tagContact({ ...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.tags.tagContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.TagContactRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.untagContact({ ...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.tags.untagContact({ - contact_id: "63a07ddf05a32042dffac965", - tag_id: "7522907" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UntagContactRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.tagConversation({ ...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.tags.tagConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.TagConversationRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.untagConversation({ ...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.tags.untagConversation({ - conversation_id: "64619700005694", - tag_id: "7522907", - admin_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UntagConversationRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.list() -> Intercom.TagList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all tags for a given workspace. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tags.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.create({ ...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.tags.create({ - name: "test" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.TagsCreateRequestBody` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.find({ ...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.tags.find({ - tag_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindTagRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.delete({ ...params }) -> void -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete the details of tags that are on the workspace by passing in the id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tags.delete({ - tag_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteTagRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.tagTicket({ ...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.tags.tagTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.TagTicketRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tags.untagTicket({ ...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.tags.untagTicket({ - ticket_id: "64619700005694", - tag_id: "7522907", - admin_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UntagTicketRequest` - -
-
- -
-
- -**requestOptions:** `TagsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Conversations -
client.conversations.list({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.conversations.list({ - per_page: 1, - starting_after: "starting_after" -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.conversations.list({ - per_page: 1, - starting_after: "starting_after" -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListConversationsRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.create({ ...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.conversations.create({ - from: { - type: "user", - id: "6762f11b1bb69f9f2193bba3" - }, - body: "Hello there" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.find({ ...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.conversations.find({ - conversation_id: "123", - display_as: "plaintext", - include_translations: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.update({ ...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.conversations.update({ - conversation_id: "conversation_id", - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - "issue_type": "Billing", - "priority": "High" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.deleteConversation({ ...params }) -> Intercom.ConversationDeleted -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single conversation. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.conversations.deleteConversation({ - conversation_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.search({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.conversations.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.conversations.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.SearchRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.reply({ ...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.conversations.reply({ - conversation_id: "123 or \"last\"", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ReplyToConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.manage({ ...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.conversations.manage({ - conversation_id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ManageConversationPartsRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.attachContactAsAdmin({ ...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.conversations.attachContactAsAdmin({ - conversation_id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19b1bb69f9f2193bbd4" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.AttachContactToConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.detachContactAsAdmin({ ...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.conversations.detachContactAsAdmin({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DetachContactFromConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.redactConversationPart({ ...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.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.RedactConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.convertToTicket({ ...params }) -> Intercom.Ticket | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can convert a conversation to a ticket. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.conversations.convertToTicket({ - conversation_id: 1, - ticket_type_id: "53" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ConvertConversationToTicketRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.conversations.runAssignmentRules({ ...params }) -> Intercom.Conversation -
-
- -#### 📝 Description - -
-
- -
-
- -{% admonition type="danger" name="Deprecation of Run Assignment Rules" %} -Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. -{% /admonition %} -You can let a conversation be automatically assigned following assignment rules. -{% admonition type="warning" name="When using workflows" %} -It is not possible to use this endpoint with Workflows. -{% /admonition %} -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.conversations.runAssignmentRules({ - conversation_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.AutoAssignConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Custom Channel Events -
client.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CustomChannelBaseEvent` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.NotifyNewMessageRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.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.NotifyQuickReplySelectedRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value" - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.NotifyAttributeCollectedRequest` - -
-
- -
-
- -**requestOptions:** `CustomChannelEventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Custom Object Instances -
client.customObjectInstances.getCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstance | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -Fetch a Custom Object Instance by external_id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - external_id: "external_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.GetCustomObjectInstancesByExternalIdRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customObjectInstances.createCustomObjectInstances({ ...params }) -> Intercom.CustomObjectInstance | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -Create or update a custom object instance -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.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.CreateOrUpdateCustomObjectInstanceRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customObjectInstances.deleteCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstanceDeleted -
-
- -#### 📝 Description - -
-
- -
-
- -Delete a single Custom Object instance by external_id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - external_id: "external_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteCustomObjectInstancesByIdRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customObjectInstances.getCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstance | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -Fetch a Custom Object Instance by id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - custom_object_instance_id: "custom_object_instance_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.GetCustomObjectInstancesByIdRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstanceDeleted -
-
- -#### 📝 Description - -
-
- -
-
- -Delete a single Custom Object instance using the Intercom defined id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - custom_object_instance_id: "custom_object_instance_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteCustomObjectInstancesByExternalIdRequest` - -
-
- -
-
- -**requestOptions:** `CustomObjectInstancesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Data Attributes -
client.dataAttributes.list({ ...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.dataAttributes.list({ - model: "contact", - include_archived: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListDataAttributesRequest` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataAttributes.create({ ...params }) -> Intercom.DataAttribute -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a data attributes for a `contact` or a `company`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.dataAttributes.create({ - data_type: "string" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateDataAttributeRequest` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.dataAttributes.update({ ...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.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [{ - value: "1-10" - }, { - value: "11-20" - }] - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateDataAttributeRequest` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Events -
client.events.list({ ...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.events.list({ - user_id: "user_id", - intercom_user_id: "intercom_user_id", - email: "email", - type: "type", - summary: true, - per_page: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListEventsRequest` - -
-
- -
-
- -**requestOptions:** `EventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.events.create({ ...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.events.create({ - id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - event_name: "invited-friend", - created_at: 1671028894 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateDataEventRequest` - -
-
- -
-
- -**requestOptions:** `EventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.events.summaries({ ...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.events.summaries(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListEventSummariesRequest` - -
-
- -
-
- -**requestOptions:** `EventsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Jobs -
client.jobs.status({ ...params }) -> Intercom.Jobs -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve the status of job execution. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.jobs.status({ - job_id: "job_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.JobsStatusRequest` - -
-
- -
-
- -**requestOptions:** `JobsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Messages -
client.messages.create({ ...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 or an email. - -> 🚧 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.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051 - }, - to: { - type: "user", - id: "536e564f316c83104c000020" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateMessageRequest` - -
-
- -
-
- -**requestOptions:** `MessagesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Segments -
client.segments.list({ ...params }) -> Intercom.SegmentList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all segments. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.segments.list({ - include_count: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListSegmentsRequest` - -
-
- -
-
- -**requestOptions:** `SegmentsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.segments.find({ ...params }) -> Intercom.Segment -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single segment. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.segments.find({ - segment_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindSegmentRequest` - -
-
- -
-
- -**requestOptions:** `SegmentsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Subscription Types -
client.subscriptionTypes.list() -> Intercom.SubscriptionTypeList -
-
- -#### 📝 Description - -
-
- -
-
- -You can list all subscription types. A list of subscription type objects will be returned. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.subscriptionTypes.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `SubscriptionTypesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## PhoneCallRedirects -
client.phoneCallRedirects.create({ ...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.phoneCallRedirects.create({ - phone: "+353832345678", - custom_attributes: { - "issue_type": "Billing", - "priority": "High" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreatePhoneSwitchRequest` - -
-
- -
-
- -**requestOptions:** `PhoneCallRedirectsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Calls -
client.calls.listCalls({ ...params }) -> Intercom.CallList -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a paginated list of calls. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.calls.listCalls({ - page: 1, - per_page: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListCallsRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.calls.showCall({ ...params }) -> Intercom.Call -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a single call by id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.calls.showCall({ - call_id: "call_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ShowCallRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.calls.showCallRecording({ ...params }) -> void -
-
- -#### 📝 Description - -
-
- -
-
- -Redirects to a signed URL for the call's recording if it exists. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.calls.showCallRecording({ - call_id: "call_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ShowCallRecordingRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.calls.showCallTranscript({ ...params }) -> string -
-
- -#### 📝 Description - -
-
- -
-
- -Returns the transcript for the specified call as a downloadable text file. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.calls.showCallTranscript({ - call_id: "call_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ShowCallTranscriptRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.calls.listCallsWithTranscripts({ ...params }) -> Intercom.ListCallsWithTranscriptsResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve calls by a list of conversation ids and include transcripts when available. -A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.calls.listCallsWithTranscripts({ - conversation_ids: ["64619700005694", "64619700005695"] -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ListCallsWithTranscriptsRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Teams -
client.teams.list() -> Intercom.TeamList -
-
- -#### 📝 Description - -
-
- -
-
- -This will return a list of team objects for the App. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.teams.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `TeamsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.teams.find({ ...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.teams.find({ - team_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindTeamRequest` - -
-
- -
-
- -**requestOptions:** `TeamsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Ticket States -
client.ticketStates.listTicketStates() -> Intercom.TicketStateList -
-
- -#### 📝 Description - -
-
- -
-
- -You can get a list of all ticket states for a workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketStates.listTicketStates(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `TicketStatesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Ticket Types -
client.ticketTypes.list() -> Intercom.TicketTypeList -
-
- -#### 📝 Description - -
-
- -
-
- -You can get a list of all ticket types for a workspace. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketTypes.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `TicketTypesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.ticketTypes.create({ ...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.ticketTypes.create({ - name: "Customer Issue", - description: "Customer Report Template", - category: "Customer", - icon: "\uD83C\uDF9F\uFE0F" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateTicketTypeRequest` - -
-
- -
-
- -**requestOptions:** `TicketTypesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.ticketTypes.get({ ...params }) -> Intercom.TicketType | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single ticket type. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketTypes.get({ - ticket_type_id: "ticket_type_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindTicketTypeRequest` - -
-
- -
-
- -**requestOptions:** `TicketTypesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.ticketTypes.update({ ...params }) -> Intercom.TicketType | undefined -
-
- -#### 📝 Description - -
-
- -
-
- - -You can update a ticket type. - -> 📘 Updating a ticket type. -> -> For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketTypes.update({ - ticket_type_id: "ticket_type_id", - name: "Bug Report 2" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateTicketTypeRequest` - -
-
- -
-
- -**requestOptions:** `TicketTypesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Tickets -
client.tickets.reply({ ...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.tickets.reply({ - ticket_id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ReplyToTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tickets.create({ ...params }) -> Intercom.Ticket | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a new ticket. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tickets.create({ - ticket_type_id: "1234", - contacts: [{ - id: "6762f2d81bb69f9f2193bc54" - }] -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.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.tickets.enqueueCreateTicket({ - ticket_type_id: "1234", - contacts: [{ - id: "6762f2d81bb69f9f2193bc54" - }] -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.EnqueueCreateTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tickets.get({ ...params }) -> Intercom.Ticket | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single ticket. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tickets.get({ - ticket_id: "ticket_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tickets.update({ ...params }) -> Intercom.Ticket | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can update a ticket. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tickets.update({ - ticket_id: "ticket_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.UpdateTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tickets.deleteTicket({ ...params }) -> Intercom.DeleteTicketResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a ticket using the Intercom provided ID. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.tickets.deleteTicket({ - ticket_id: "ticket_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.DeleteTicketRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.tickets.search({ ...params }) -> core.Page<(Intercom.Ticket | undefined), 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) | -| title | String | -| 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 | - -{% admonition type="info" name="Searching by Category" %} -When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: -* For **Customer** category tickets, use the term `request`. -* For **Back-office** category tickets, use the term `task`. -* For **Tracker** category tickets, use the term `tracker`. -{% /admonition %} - -### Accepted Operators - -{% admonition type="info" name="Searching based on `created_at`" %} - 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 -const pageableResponse = await client.tickets.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.tickets.search({ - query: { - operator: "AND", - value: [{ - field: "created_at", - operator: ">", - value: "1306054154" - }] - }, - pagination: { - per_page: 5 - } -}); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.SearchRequest` - -
-
- -
-
- -**requestOptions:** `TicketsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Visitors -
client.visitors.find({ ...params }) -> Intercom.Visitor | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single visitor. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.visitors.find({ - user_id: "user_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.FindVisitorRequest` - -
-
- -
-
- -**requestOptions:** `VisitorsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.visitors.update({ ...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.visitors.update({ - id: "6762f30c1bb69f9f2193bc5e", - name: "Gareth Bale" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.UpdateVisitorRequest` - -
-
- -
-
- -**requestOptions:** `VisitorsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.visitors.mergeToContact({ ...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.visitors.mergeToContact({ - type: "user", - user: { - id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - email: "foo@bar.com" - }, - visitor: { - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.MergeVisitorToContactRequest` - -
-
- -
-
- -**requestOptions:** `VisitorsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## HelpCenters Collections -
client.helpCenters.collections.list({ ...params }) -> core.Page -
-
- -#### 📝 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 -const pageableResponse = await client.helpCenters.collections.list(); -for await (const item of pageableResponse) { - console.log(item); -} - -// Or you can manually iterate page-by-page -let page = await client.helpCenters.collections.list(); -while (page.hasNextPage()) { - page = page.getNextPage(); -} - -// You can also access the underlying response -const response = page.response; - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.helpCenters.ListCollectionsRequest` - -
-
- -
-
- -**requestOptions:** `CollectionsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.helpCenters.collections.create({ ...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.helpCenters.collections.create({ - name: "Thanks for everything" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.helpCenters.CreateCollectionRequest` - -
-
- -
-
- -**requestOptions:** `CollectionsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.helpCenters.collections.find({ ...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.helpCenters.collections.find({ - collection_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.helpCenters.FindCollectionRequest` - -
-
- -
-
- -**requestOptions:** `CollectionsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.helpCenters.collections.update({ ...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.helpCenters.collections.update({ - collection_id: 1, - name: "Update collection name" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.helpCenters.UpdateCollectionRequest` - -
-
- -
-
- -**requestOptions:** `CollectionsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.helpCenters.collections.delete({ ...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.helpCenters.collections.delete({ - collection_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.helpCenters.DeleteCollectionRequest` - -
-
- -
-
- -**requestOptions:** `CollectionsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## News Items -
client.news.items.list() -> Intercom.PaginatedResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all news items -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.items.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `ItemsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.items.create({ ...params }) -> Intercom.NewsItem -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a news item -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.items.create({ - 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:** `ItemsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.items.find({ ...params }) -> Intercom.NewsItem -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single news item. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.items.find({ - news_item_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.news.FindNewsItemRequest` - -
-
- -
-
- -**requestOptions:** `ItemsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.items.update({ ...params }) -> Intercom.NewsItem -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.items.update({ - news_item_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.news.UpdateNewsItemRequest` - -
-
- -
-
- -**requestOptions:** `ItemsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.items.delete({ ...params }) -> Intercom.DeletedObject -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single news item. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.items.delete({ - news_item_id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.news.DeleteNewsItemRequest` - -
-
- -
-
- -**requestOptions:** `ItemsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## News Feeds -
client.news.feeds.listItems({ ...params }) -> Intercom.PaginatedResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all news items that are live on a given newsfeed -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.feeds.listItems({ - newsfeed_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.news.ListNewsFeedItemsRequest` - -
-
- -
-
- -**requestOptions:** `FeedsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.feeds.list() -> Intercom.PaginatedResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all newsfeeds -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.feeds.list(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `FeedsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.news.feeds.find({ ...params }) -> Intercom.Newsfeed -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single newsfeed -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.news.feeds.find({ - newsfeed_id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.news.FindNewsFeedRequest` - -
-
- -
-
- -**requestOptions:** `FeedsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## TicketTypes Attributes -
client.ticketTypes.attributes.create({ ...params }) -> Intercom.TicketTypeAttribute | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a new attribute for a ticket type. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketTypes.attributes.create({ - ticket_type_id: "ticket_type_id", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ticketTypes.CreateTicketTypeAttributeRequest` - -
-
- -
-
- -**requestOptions:** `AttributesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.ticketTypes.attributes.update({ ...params }) -> Intercom.TicketTypeAttribute | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can update an existing attribute for a ticket type. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.ticketTypes.attributes.update({ - ticket_type_id: "ticket_type_id", - attribute_id: "attribute_id", - description: "New Attribute Description" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.ticketTypes.UpdateTicketTypeAttributeRequest` - -
-
- -
-
- -**requestOptions:** `AttributesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## 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:** `AdminsClient.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:** `AdminsClient.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:** `AdminsClient.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:** `AdminsClient.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:** `AdminsClient.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:** `AiContentClient.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:** `AiContentClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.aiContent.getContentImportSource({ ...params }) -> Intercom.ContentImportSource -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.aiContent.getContentImportSource({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.GetContentImportSourceRequest` - -
-
- -
-
- -**requestOptions:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `AiContentClient.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:** `ArticlesClient.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:** `ArticlesClient.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:** `ArticlesClient.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:** `ArticlesClient.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", - help_center_id: 1, - highlight: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.SearchArticlesRequest` - -
-
- -
-
- -**requestOptions:** `ArticlesClient.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:** `AwayStatusReasonsClient.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_started_at"], - start_time: 1717490000, - end_time: 1717510000 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.PostExportReportingDataEnqueueRequest` - -
-
- -
-
- -**requestOptions:** `ExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.export.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.export.listAvailableDatasetsAndAttributes(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `ExportClient.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:** `HelpCenterClient.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:** `HelpCenterClient.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:** `HelpCenterClient.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:** `HelpCenterClient.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:** `HelpCenterClient.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:** `HelpCenterClient.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:** `HelpCenterClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Internal Articles -
client.unstable.internalArticles.listInternalArticles() -> Intercom.InternalArticleList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.listInternalArticles(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.internalArticles.createInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.CreateInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.internalArticles.retrieveInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.retrieveInternalArticle({ - id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.RetrieveInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.internalArticles.updateInternalArticle({ ...params }) -> Intercom.InternalArticle -
-
- -#### 📝 Description - -
-
- -
-
- -You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.UpdateInternalArticleRequestBody` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.internalArticles.deleteInternalArticle({ ...params }) -> Intercom.DeletedInternalArticleObject -
-
- -#### 📝 Description - -
-
- -
-
- -You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.deleteInternalArticle({ - id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.DeleteInternalArticleRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.internalArticles.searchInternalArticles({ ...params }) -> Intercom.InternalArticleSearchResponse -
-
- -#### 📝 Description - -
-
- -
-
- -You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.internalArticles.searchInternalArticles({ - folder_id: "folder_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.SearchInternalArticlesRequest` - -
-
- -
-
- -**requestOptions:** `InternalArticlesClient.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", - page: 1, - per_page: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.RetrieveCompanyRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.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({ - page: 1, - per_page: 1, - order: "desc" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListAllCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.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({ - scroll_param: "scroll_param" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ScrollOverAllCompaniesRequest` - -
-
- -
-
- -**requestOptions:** `CompaniesClient.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:** `CompaniesClient.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:** `CompaniesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Notes -
client.unstable.notes.listCompanyNotes({ ...params }) -> Intercom.NoteList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of notes that are associated to a company. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.notes.listCompanyNotes({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListCompanyNotesRequest` - -
-
- -
-
- -**requestOptions:** `NotesClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
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:** `NotesClient.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:** `NotesClient.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:** `NotesClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `ContactsClient.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:** `SubscriptionTypesClient.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:** `SubscriptionTypesClient.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:** `SubscriptionTypesClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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:** `TagsClient.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({ - per_page: 1, - starting_after: "starting_after" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListConversationsRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.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:** `ConversationsClient.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", - include_translations: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.RetrieveConversationRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.conversations.listHandlingEvents({ ...params }) -> Intercom.HandlingEventList -
-
- -#### 📝 Description - -
-
- -
-
- -List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. - -Requires the `read_conversations` OAuth scope. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.conversations.listHandlingEvents({ - id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListHandlingEventsRequest` - -
-
- -
-
- -**requestOptions:** `ConversationsClient.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:** `ConversationsClient.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:** `ConversationsClient.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 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:** `CustomChannelEventsClient.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 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:** `CustomChannelEventsClient.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 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:** `CustomChannelEventsClient.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 currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. -
-
-
-
- -#### 🔌 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:** `CustomChannelEventsClient.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:** `CustomObjectInstancesClient.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:** `CustomObjectInstancesClient.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:** `CustomObjectInstancesClient.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:** `CustomObjectInstancesClient.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:** `CustomObjectInstancesClient.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({ - model: "contact", - include_archived: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.LisDataAttributesRequest` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.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({ - "key": "value" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `unknown` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.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, - body: { - "key": "value" - } -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.UpdateDataAttributeRequest` - -
-
- -
-
- -**requestOptions:** `DataAttributesClient.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:** `DataEventsClient.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:** `DataEventsClient.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:** `DataEventsClient.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:** `DataExportClient.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:** `DataExportClient.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:** `DataExportClient.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:** `DataExportClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Workflows -
client.unstable.workflows.exportWorkflow({ ...params }) -> Intercom.WorkflowExport -
-
- -#### 📝 Description - -
-
- -
-
- -Export a workflow configuration by its ID. This endpoint returns the complete workflow definition including its steps, targeting rules, and attributes. - -This endpoint is designed for EU Data Act compliance, allowing customers to export their workflow configurations. - -{% admonition type="warning" name="Unstable API" %} - This API is currently in the Unstable version. Its behavior may change in future releases. -{% /admonition %} -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.workflows.exportWorkflow({ - id: "12345" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ExportWorkflowRequest` - -
-
- -
-
- -**requestOptions:** `WorkflowsClient.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:** `JobsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Macros -
client.unstable.macros.listMacros({ ...params }) -> Intercom.MacroList -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. - -The macros are returned in descending order by updated_at. - -**Pagination** - -This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. - -**Placeholder Transformation** - -The API transforms Intercom placeholders to a more standard XML-like format: -- From: `{{user.name | fallback: 'there'}}` -- To: `` -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListMacrosRequest` - -
-
- -
-
- -**requestOptions:** `MacrosClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.macros.getMacro({ ...params }) -> Intercom.Macro | undefined -
-
- -#### 📝 Description - -
-
- -
-
- -You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. - -**Visibility Rules** - -A macro is returned based on its `visible_to` setting: -- `everyone`: Always visible to all team members -- `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` - -If a macro exists but is not visible to the authenticated user, a 404 error is returned. - -**Placeholder Transformation** - -The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: -- From: `{{user.name | fallback: 'there'}}` -- To: `` - -Default values in placeholders are HTML-escaped for security. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.macros.getMacro({ - id: "123" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.GetMacroRequest` - -
-
- -
-
- -**requestOptions:** `MacrosClient.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, sms or whatsapp. - -> 🚧 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.CreateMessageRequest | undefined` - -
-
- -
-
- -**requestOptions:** `MessagesClient.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", - per_page: 1, - starting_after: "starting_after" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.GetWhatsAppMessageStatusRequest` - -
-
- -
-
- -**requestOptions:** `MessagesClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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:** `NewsClient.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({ - include_count: true -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListSegmentsRequest` - -
-
- -
-
- -**requestOptions:** `SegmentsClient.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:** `SegmentsClient.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:** `SwitchClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Calls -
client.unstable.calls.listCalls({ ...params }) -> Intercom.CallList -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a paginated list of calls. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.listCalls({ - page: 1, - per_page: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListCallsRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.showCall({ ...params }) -> Intercom.Call -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a single call by id. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.showCall({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ShowCallRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.showCallRecording({ ...params }) -> void -
-
- -#### 📝 Description - -
-
- -
-
- -Redirects to a signed URL for the call's recording if it exists. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.showCallRecording({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ShowCallRecordingRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.showCallTranscript({ ...params }) -> string -
-
- -#### 📝 Description - -
-
- -
-
- -Returns the transcript for the specified call as a downloadable text file. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.showCallTranscript({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ShowCallTranscriptRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.listCallsWithTranscripts({ ...params }) -> Intercom.ListCallsWithTranscriptsResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve calls by a list of conversation ids and include transcripts when available. -A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.listCallsWithTranscripts({ - conversation_ids: ["64619700005694", "64619700005695"] -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.ListCallsWithTranscriptsRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.registerFinVoiceCall({ ...params }) -> Intercom.AiCallResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Register a Fin Voice call with Intercom. This endpoint creates an external reference -that links an external call identifier to an Intercom call and conversation. - -The call can be from different sources: -- AWS Connect (default) -- Five9 -- Zoom Phone -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.registerFinVoiceCall({ - phone_number: "+1234567890", - call_id: "call-123-abc" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.RegisterFinVoiceCallRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.collectFinVoiceCallById({ ...params }) -> Intercom.AiCallResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve information about a Fin Voice call using the external reference ID. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.collectFinVoiceCallById({ - id: 1 -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.CollectFinVoiceCallByIdRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.collectFinVoiceCallByExternalId({ ...params }) -> Intercom.AiCallResponse -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve information about a Fin Voice call using the external call identifier. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.collectFinVoiceCallByExternalId({ - external_id: "external_id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.CollectFinVoiceCallByExternalIdRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.calls.collectFinVoiceCallByPhoneNumber({ ...params }) -> Intercom.Error_ -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve information about a Fin Voice call using the phone number. - -Returns the most recent matched call for the given phone number, ordered by creation date. -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - phone_number: "phone_number" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest` - -
-
- -
-
- -**requestOptions:** `CallsClient.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:** `TeamsClient.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:** `TeamsClient.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:** `TicketStatesClient.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:** `TicketTypeAttributesClient.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:** `TicketTypeAttributesClient.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:** `TicketTypesClient.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:** `TicketTypesClient.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:** `TicketTypesClient.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:** `TicketsClient.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:** `TicketsClient.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:** `TicketsClient.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:** `TicketsClient.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:** `TicketsClient.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) | -| title | String | -| 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 | - -{% admonition type="info" name="Searching by Category" %} -When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: -* For **Customer** category tickets, use the term `request`. -* For **Back-office** category tickets, use the term `task`. -* For **Tracker** category tickets, use the term `tracker`. -{% /admonition %} - -### Accepted Operators - -{% admonition type="info" name="Searching based on `created_at`" %} - 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:** `TicketsClient.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:** `VisitorsClient.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:** `VisitorsClient.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:** `VisitorsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Brands -
client.unstable.brands.listBrands() -> Intercom.BrandList -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieves all brands for the workspace, including the default brand. -The default brand id always matches the workspace -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.brands.listBrands(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `BrandsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.brands.retrieveBrand({ ...params }) -> Intercom.Brand -
-
- -#### 📝 Description - -
-
- -
-
- -Fetches a specific brand by its unique identifier -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.brands.retrieveBrand({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.RetrieveBrandRequest` - -
-
- -
-
- -**requestOptions:** `BrandsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -## Emails -
client.unstable.emails.listEmails() -> Intercom.EmailList -
-
- -#### 📝 Description - -
-
- -
-
- -Lists all sender email address settings for the workspace -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.emails.listEmails(); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `EmailsClient.RequestOptions` - -
-
-
-
- - -
-
-
- -
client.unstable.emails.retrieveEmail({ ...params }) -> Intercom.EmailSetting -
-
- -#### 📝 Description - -
-
- -
-
- -Fetches a specific email setting by its unique identifier -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.unstable.emails.retrieveEmail({ - id: "id" -}); - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Intercom.unstable.RetrieveEmailRequest` - -
-
- -
-
- -**requestOptions:** `EmailsClient.RequestOptions` - -
-
-
-
- - -
-
-
diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..624ed99e --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "node", + "extra-files": [ + "src/version.ts", + "README.md" + ] +} diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..05dd47a6 --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then + brew bundle check >/dev/null 2>&1 || { + echo "==> Installing Homebrew dependencies…" + brew bundle + } +fi + +echo "==> Installing Node dependencies…" + +PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm") + +$PACKAGE_MANAGER install diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..d0c34306 --- /dev/null +++ b/scripts/build @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -exuo pipefail + +cd "$(dirname "$0")/.." + +node scripts/utils/check-version.cjs + +# Build into dist and will publish the package from there, +# so that src/resources/foo.ts becomes /resources/foo.js +# This way importing from `"intercom-client/resources/foo"` works +# even with `"moduleResolution": "node"` + +rm -rf dist; mkdir dist +# Copy src to dist/src and build from dist/src into dist, so that +# the source map for index.js.map will refer to ./src/index.ts etc +cp -rp src README.md dist +rm dist/src/_shims/*-deno.ts dist/src/_shims/auto/*-deno.ts +for file in LICENSE CHANGELOG.md; do + if [ -e "${file}" ]; then cp "${file}" dist; fi +done +if [ -e "bin/cli" ]; then + mkdir dist/bin + cp -p "bin/cli" dist/bin/; +fi +# this converts the export map paths for the dist directory +# and does a few other minor things +node scripts/utils/make-dist-package-json.cjs > dist/package.json + +# build to .js/.mjs/.d.ts files +npm exec tsc-multi +# copy over handwritten .js/.mjs/.d.ts files +cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims +cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto +# we need to add exports = module.exports = Intercom Node to index.js; +# No way to get that from index.ts because it would cause compile errors +# when building .mjs +node scripts/utils/fix-index-exports.cjs +# with "moduleResolution": "nodenext", if ESM resolves to index.d.ts, +# it'll have TS errors on the default import. But if it resolves to +# index.d.mts the default import will work (even though both files have +# the same export default statement) +cp dist/index.d.ts dist/index.d.mts +cp tsconfig.dist-src.json dist/src/tsconfig.json + +node scripts/utils/postprocess-files.cjs + +# make sure that nothing crashes when we require the output CJS or +# import the output ESM +(cd dist && node -e 'require("intercom-client")') +(cd dist && node -e 'import("intercom-client")' --input-type=module) + +if command -v deno &> /dev/null && [ -e ./scripts/build-deno ] +then + ./scripts/build-deno +fi diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..d297e762 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running eslint --fix" +./node_modules/.bin/eslint --fix --ext ts,js . diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..6b0e5dc3 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running eslint" +./node_modules/.bin/eslint --ext ts,js . diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..f5861576 --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" +fi diff --git a/scripts/rename-to-esm-files.js b/scripts/rename-to-esm-files.js deleted file mode 100644 index dc1df1cb..00000000 --- a/scripts/rename-to-esm-files.js +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env node - -const fs = require("fs").promises; -const path = require("path"); - -const extensionMap = { - ".js": ".mjs", - ".d.ts": ".d.mts", -}; -const oldExtensions = Object.keys(extensionMap); - -async function findFiles(rootPath) { - const files = []; - - async function scan(directory) { - const entries = await fs.readdir(directory, { withFileTypes: true }); - - for (const entry of entries) { - const fullPath = path.join(directory, entry.name); - - if (entry.isDirectory()) { - if (entry.name !== "node_modules" && !entry.name.startsWith(".")) { - await scan(fullPath); - } - } else if (entry.isFile()) { - if (oldExtensions.some((ext) => entry.name.endsWith(ext))) { - files.push(fullPath); - } - } - } - } - - await scan(rootPath); - return files; -} - -async function updateFiles(files) { - const updatedFiles = []; - for (const file of files) { - const updated = await updateFileContents(file); - updatedFiles.push(updated); - } - - console.log(`Updated imports in ${updatedFiles.length} files.`); -} - -async function updateFileContents(file) { - const content = await fs.readFile(file, "utf8"); - - let newContent = content; - // Update each extension type defined in the map - for (const [oldExt, newExt] of Object.entries(extensionMap)) { - // Handle static imports/exports - const staticRegex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g"); - newContent = newContent.replace(staticRegex, `$1$2$3${newExt}$5`); - - // Handle dynamic imports (yield import, await import, regular import()) - const dynamicRegex = new RegExp( - `(yield\\s+import|await\\s+import|import)\\s*\\(\\s*['"](\\.\\.\?\\/[^'"]+)(\\${oldExt})['"]\\s*\\)`, - "g", - ); - newContent = newContent.replace(dynamicRegex, `$1("$2${newExt}")`); - } - - if (content !== newContent) { - await fs.writeFile(file, newContent, "utf8"); - return true; - } - return false; -} - -async function renameFiles(files) { - let counter = 0; - for (const file of files) { - const ext = oldExtensions.find((ext) => file.endsWith(ext)); - const newExt = extensionMap[ext]; - - if (newExt) { - const newPath = file.slice(0, -ext.length) + newExt; - await fs.rename(file, newPath); - counter++; - } - } - - console.log(`Renamed ${counter} files.`); -} - -async function main() { - try { - const targetDir = process.argv[2]; - if (!targetDir) { - console.error("Please provide a target directory"); - process.exit(1); - } - - const targetPath = path.resolve(targetDir); - const targetStats = await fs.stat(targetPath); - - if (!targetStats.isDirectory()) { - console.error("The provided path is not a directory"); - process.exit(1); - } - - console.log(`Scanning directory: ${targetDir}`); - - const files = await findFiles(targetDir); - - if (files.length === 0) { - console.log("No matching files found."); - process.exit(0); - } - - console.log(`Found ${files.length} files.`); - await updateFiles(files); - await renameFiles(files); - console.log("\nDone!"); - } catch (error) { - console.error("An error occurred:", error.message); - process.exit(1); - } -} - -main(); diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..2049e31b --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./node_modules/.bin/jest "$@" diff --git a/scripts/utils/check-is-in-git-install.sh b/scripts/utils/check-is-in-git-install.sh new file mode 100755 index 00000000..36bcedc2 --- /dev/null +++ b/scripts/utils/check-is-in-git-install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Check if you happen to call prepare for a repository that's already in node_modules. +[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] || +# The name of the containing directory that 'npm` uses, which looks like +# $HOME/.npm/_cacache/git-cloneXXXXXX +[ "$(basename "$(dirname "$PWD")")" = 'tmp' ] || +# The name of the containing directory that 'yarn` uses, which looks like +# $(yarn cache dir)/.tmp/XXXXX +[ "$(basename "$(dirname "$PWD")")" = '.tmp' ] diff --git a/scripts/utils/check-version.cjs b/scripts/utils/check-version.cjs new file mode 100644 index 00000000..86c56dfd --- /dev/null +++ b/scripts/utils/check-version.cjs @@ -0,0 +1,20 @@ +const fs = require('fs'); +const path = require('path'); + +const main = () => { + const pkg = require('../../package.json'); + const version = pkg['version']; + if (!version) throw 'The version property is not set in the package.json file'; + if (typeof version !== 'string') { + throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`; + } + + const versionFile = path.resolve(__dirname, '..', '..', 'src', 'version.ts'); + const contents = fs.readFileSync(versionFile, 'utf8'); + const output = contents.replace(/(export const VERSION = ')(.*)(')/g, `$1${version}$3`); + fs.writeFileSync(versionFile, output); +}; + +if (require.main === module) { + main(); +} diff --git a/scripts/utils/fix-index-exports.cjs b/scripts/utils/fix-index-exports.cjs new file mode 100644 index 00000000..72b0b8fd --- /dev/null +++ b/scripts/utils/fix-index-exports.cjs @@ -0,0 +1,14 @@ +const fs = require('fs'); +const path = require('path'); + +const indexJs = + process.env['DIST_PATH'] ? + path.resolve(process.env['DIST_PATH'], 'index.js') + : path.resolve(__dirname, '..', '..', 'dist', 'index.js'); + +let before = fs.readFileSync(indexJs, 'utf8'); +let after = before.replace( + /^\s*exports\.default\s*=\s*(\w+)/m, + 'exports = module.exports = $1;\nexports.default = $1', +); +fs.writeFileSync(indexJs, after, 'utf8'); diff --git a/scripts/utils/make-dist-package-json.cjs b/scripts/utils/make-dist-package-json.cjs new file mode 100644 index 00000000..7c24f56e --- /dev/null +++ b/scripts/utils/make-dist-package-json.cjs @@ -0,0 +1,21 @@ +const pkgJson = require(process.env['PKG_JSON_PATH'] || '../../package.json'); + +function processExportMap(m) { + for (const key in m) { + const value = m[key]; + if (typeof value === 'string') m[key] = value.replace(/^\.\/dist\//, './'); + else processExportMap(value); + } +} +processExportMap(pkgJson.exports); + +for (const key of ['types', 'main', 'module']) { + if (typeof pkgJson[key] === 'string') pkgJson[key] = pkgJson[key].replace(/^(\.\/)?dist\//, './'); +} + +delete pkgJson.devDependencies; +delete pkgJson.scripts.prepack; +delete pkgJson.scripts.prepublishOnly; +delete pkgJson.scripts.prepare; + +console.log(JSON.stringify(pkgJson, null, 2)); diff --git a/scripts/utils/postprocess-files.cjs b/scripts/utils/postprocess-files.cjs new file mode 100644 index 00000000..d39e67a2 --- /dev/null +++ b/scripts/utils/postprocess-files.cjs @@ -0,0 +1,165 @@ +const fs = require('fs'); +const path = require('path'); +const { parse } = require('@typescript-eslint/parser'); + +const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'intercom-client/'; + +const distDir = + process.env['DIST_PATH'] ? + path.resolve(process.env['DIST_PATH']) + : path.resolve(__dirname, '..', '..', 'dist'); +const distSrcDir = path.join(distDir, 'src'); + +/** + * Quick and dirty AST traversal + */ +function traverse(node, visitor) { + if (!node || typeof node.type !== 'string') return; + visitor.node?.(node); + visitor[node.type]?.(node); + for (const key in node) { + const value = node[key]; + if (Array.isArray(value)) { + for (const elem of value) traverse(elem, visitor); + } else if (value instanceof Object) { + traverse(value, visitor); + } + } +} + +/** + * Helper method for replacing arbitrary ranges of text in input code. + * + * The `replacer` is a function that will be called with a mini-api. For example: + * + * replaceRanges('foobar', ({ replace }) => replace([0, 3], 'baz')) // 'bazbar' + * + * The replaced ranges must not be overlapping. + */ +function replaceRanges(code, replacer) { + const replacements = []; + replacer({ replace: (range, replacement) => replacements.push({ range, replacement }) }); + + if (!replacements.length) return code; + replacements.sort((a, b) => a.range[0] - b.range[0]); + const overlapIndex = replacements.findIndex( + (r, index) => index > 0 && replacements[index - 1].range[1] > r.range[0], + ); + if (overlapIndex >= 0) { + throw new Error( + `replacements overlap: ${JSON.stringify(replacements[overlapIndex - 1])} and ${JSON.stringify( + replacements[overlapIndex], + )}`, + ); + } + + const parts = []; + let end = 0; + for (const { + range: [from, to], + replacement, + } of replacements) { + if (from > end) parts.push(code.substring(end, from)); + parts.push(replacement); + end = to; + } + if (end < code.length) parts.push(code.substring(end)); + return parts.join(''); +} + +/** + * Like calling .map(), where the iteratee is called on the path in every import or export from statement. + * @returns the transformed code + */ +function mapModulePaths(code, iteratee) { + const ast = parse(code, { range: true }); + return replaceRanges(code, ({ replace }) => + traverse(ast, { + node(node) { + switch (node.type) { + case 'ImportDeclaration': + case 'ExportNamedDeclaration': + case 'ExportAllDeclaration': + case 'ImportExpression': + if (node.source) { + const { range, value } = node.source; + const transformed = iteratee(value); + if (transformed !== value) { + replace(range, JSON.stringify(transformed)); + } + } + } + }, + }), + ); +} + +async function* walk(dir) { + for await (const d of await fs.promises.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; + } +} + +async function postprocess() { + for await (const file of walk(path.resolve(__dirname, '..', '..', 'dist'))) { + if (!/\.([cm]?js|(\.d)?[cm]?ts)$/.test(file)) continue; + + const code = await fs.promises.readFile(file, 'utf8'); + + let transformed = mapModulePaths(code, (importPath) => { + if (file.startsWith(distSrcDir)) { + if (importPath.startsWith(pkgImportPath)) { + // convert self-references in dist/src to relative paths + let relativePath = path.relative( + path.dirname(file), + path.join(distSrcDir, importPath.substring(pkgImportPath.length)), + ); + if (!relativePath.startsWith('.')) relativePath = `./${relativePath}`; + return relativePath; + } + return importPath; + } + if (importPath.startsWith('.')) { + // add explicit file extensions to relative imports + const { dir, name } = path.parse(importPath); + const ext = /\.mjs$/.test(file) ? '.mjs' : '.js'; + return `${dir}/${name}${ext}`; + } + return importPath; + }); + + if (file.startsWith(distSrcDir) && !file.endsWith('_shims/index.d.ts')) { + // strip out `unknown extends Foo ? never :` shim guards in dist/src + // to prevent errors from appearing in Go To Source + transformed = transformed.replace( + new RegExp('unknown extends (typeof )?\\S+ \\? \\S+ :\\s*'.replace(/\s+/, '\\s+'), 'gm'), + // replace with same number of characters to avoid breaking source maps + (match) => ' '.repeat(match.length), + ); + } + + if (file.endsWith('.d.ts')) { + // work around bad tsc behavior + // if we have `import { type Readable } from 'intercom-client/_shims/index'`, + // tsc sometimes replaces `Readable` with `import("stream").Readable` inline + // in the output .d.ts + transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable'); + } + + // strip out lib="dom" and types="node" references; these are needed at build time, + // but would pollute the user's TS environment + transformed = transformed.replace( + /^ *\/\/\/ * ' '.repeat(match.length - 1) + '\n', + ); + + if (transformed !== code) { + await fs.promises.writeFile(file, transformed, 'utf8'); + console.error(`wrote ${path.relative(process.cwd(), file)}`); + } + } +} +postprocess(); diff --git a/src/BaseClient.ts b/src/BaseClient.ts deleted file mode 100644 index 1c4b0442..00000000 --- a/src/BaseClient.ts +++ /dev/null @@ -1,131 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import { BearerAuthProvider } from "./auth/BearerAuthProvider.js"; -import { mergeHeaders } from "./core/headers.js"; -import * as core from "./core/index.js"; -import type * as environments from "./environments.js"; - -export interface BaseClientOptions { - 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" - | "2.12" - | "2.13" - | "2.14" - | "Unstable"; - /** Additional headers to include in requests. */ - headers?: Record | null | undefined>; - /** The default maximum time to wait for a response in seconds. */ - timeoutInSeconds?: number; - /** The default number of times to retry the request. Defaults to 2. */ - maxRetries?: number; - /** Provide a custom fetch implementation. Useful for platforms that don't have a built-in fetch or need a custom implementation. */ - fetch?: typeof fetch; - fetcher?: core.FetchFunction; - /** Configure logging for the client. */ - logging?: core.logging.LogConfig | core.logging.Logger; -} - -export interface BaseRequestOptions { - /** 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 query string parameters to include in the request. */ - queryParams?: Record; - /** Additional headers to include in the request. */ - headers?: Record | null | undefined>; - /** 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" - | "2.12" - | "2.13" - | "2.14" - | "Unstable"; -} - -export type NormalizedClientOptions = T & { - logging: core.logging.Logger; - authProvider?: core.AuthProvider; -}; - -export type NormalizedClientOptionsWithAuth = NormalizedClientOptions & { - authProvider: core.AuthProvider; -}; - -export function normalizeClientOptions(options: T): NormalizedClientOptions { - const headers = mergeHeaders( - { - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "7.0.3", - "User-Agent": "intercom-client/7.0.3", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - "Intercom-Version": options?.version ?? "2.14", - }, - options?.headers, - ); - - return { - ...options, - logging: core.logging.createLogger(options?.logging), - headers, - } as NormalizedClientOptions; -} - -export function normalizeClientOptionsWithAuth( - options: T, -): NormalizedClientOptionsWithAuth { - const normalized = normalizeClientOptions(options) as NormalizedClientOptionsWithAuth; - const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized); - normalized.authProvider ??= new BearerAuthProvider(normalizedWithNoOpAuthProvider); - return normalized; -} - -function withNoOpAuthProvider( - options: NormalizedClientOptions, -): NormalizedClientOptionsWithAuth { - return { - ...options, - authProvider: new core.NoOpAuthProvider(), - }; -} diff --git a/src/Client.ts b/src/Client.ts deleted file mode 100644 index db9d639f..00000000 --- a/src/Client.ts +++ /dev/null @@ -1,204 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import { AdminsClient } from "./api/resources/admins/client/Client.js"; -import { AiContentClient } from "./api/resources/aiContent/client/Client.js"; -import { ArticlesClient } from "./api/resources/articles/client/Client.js"; -import { AwayStatusReasonsClient } from "./api/resources/awayStatusReasons/client/Client.js"; -import { CallsClient } from "./api/resources/calls/client/Client.js"; -import { CompaniesClient } from "./api/resources/companies/client/Client.js"; -import { ContactsClient } from "./api/resources/contacts/client/Client.js"; -import { ConversationsClient } from "./api/resources/conversations/client/Client.js"; -import { CustomChannelEventsClient } from "./api/resources/customChannelEvents/client/Client.js"; -import { CustomObjectInstancesClient } from "./api/resources/customObjectInstances/client/Client.js"; -import { DataAttributesClient } from "./api/resources/dataAttributes/client/Client.js"; -import { DataExportClient } from "./api/resources/dataExport/client/Client.js"; -import { EventsClient } from "./api/resources/events/client/Client.js"; -import { ExportClient } from "./api/resources/export/client/Client.js"; -import { HelpCentersClient } from "./api/resources/helpCenters/client/Client.js"; -import { InternalArticlesClient } from "./api/resources/internalArticles/client/Client.js"; -import { IpAllowlistClient } from "./api/resources/ipAllowlist/client/Client.js"; -import { JobsClient } from "./api/resources/jobs/client/Client.js"; -import { MessagesClient } from "./api/resources/messages/client/Client.js"; -import { NewsClient } from "./api/resources/news/client/Client.js"; -import { NotesClient } from "./api/resources/notes/client/Client.js"; -import { PhoneCallRedirectsClient } from "./api/resources/phoneCallRedirects/client/Client.js"; -import { SegmentsClient } from "./api/resources/segments/client/Client.js"; -import { SubscriptionTypesClient } from "./api/resources/subscriptionTypes/client/Client.js"; -import { TagsClient } from "./api/resources/tags/client/Client.js"; -import { TeamsClient } from "./api/resources/teams/client/Client.js"; -import { TicketStatesClient } from "./api/resources/ticketStates/client/Client.js"; -import { TicketsClient } from "./api/resources/tickets/client/Client.js"; -import { TicketTypesClient } from "./api/resources/ticketTypes/client/Client.js"; -import { UnstableClient } from "./api/resources/unstable/client/Client.js"; -import { VisitorsClient } from "./api/resources/visitors/client/Client.js"; -import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js"; - -export declare namespace IntercomClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class IntercomClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - protected _admins: AdminsClient | undefined; - protected _aiContent: AiContentClient | undefined; - protected _articles: ArticlesClient | undefined; - protected _awayStatusReasons: AwayStatusReasonsClient | undefined; - protected _export: ExportClient | undefined; - protected _dataExport: DataExportClient | undefined; - protected _helpCenters: HelpCentersClient | undefined; - protected _internalArticles: InternalArticlesClient | undefined; - protected _ipAllowlist: IpAllowlistClient | undefined; - protected _companies: CompaniesClient | undefined; - protected _contacts: ContactsClient | undefined; - protected _notes: NotesClient | undefined; - protected _tags: TagsClient | undefined; - protected _conversations: ConversationsClient | undefined; - protected _customChannelEvents: CustomChannelEventsClient | undefined; - protected _customObjectInstances: CustomObjectInstancesClient | undefined; - protected _dataAttributes: DataAttributesClient | undefined; - protected _events: EventsClient | undefined; - protected _jobs: JobsClient | undefined; - protected _messages: MessagesClient | undefined; - protected _segments: SegmentsClient | undefined; - protected _subscriptionTypes: SubscriptionTypesClient | undefined; - protected _phoneCallRedirects: PhoneCallRedirectsClient | undefined; - protected _calls: CallsClient | undefined; - protected _teams: TeamsClient | undefined; - protected _ticketStates: TicketStatesClient | undefined; - protected _ticketTypes: TicketTypesClient | undefined; - protected _tickets: TicketsClient | undefined; - protected _visitors: VisitorsClient | undefined; - protected _news: NewsClient | undefined; - protected _unstable: UnstableClient | undefined; - - constructor(options: IntercomClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - public get admins(): AdminsClient { - return (this._admins ??= new AdminsClient(this._options)); - } - - public get aiContent(): AiContentClient { - return (this._aiContent ??= new AiContentClient(this._options)); - } - - public get articles(): ArticlesClient { - return (this._articles ??= new ArticlesClient(this._options)); - } - - public get awayStatusReasons(): AwayStatusReasonsClient { - return (this._awayStatusReasons ??= new AwayStatusReasonsClient(this._options)); - } - - public get export(): ExportClient { - return (this._export ??= new ExportClient(this._options)); - } - - public get dataExport(): DataExportClient { - return (this._dataExport ??= new DataExportClient(this._options)); - } - - public get helpCenters(): HelpCentersClient { - return (this._helpCenters ??= new HelpCentersClient(this._options)); - } - - public get internalArticles(): InternalArticlesClient { - return (this._internalArticles ??= new InternalArticlesClient(this._options)); - } - - public get ipAllowlist(): IpAllowlistClient { - return (this._ipAllowlist ??= new IpAllowlistClient(this._options)); - } - - public get companies(): CompaniesClient { - return (this._companies ??= new CompaniesClient(this._options)); - } - - public get contacts(): ContactsClient { - return (this._contacts ??= new ContactsClient(this._options)); - } - - public get notes(): NotesClient { - return (this._notes ??= new NotesClient(this._options)); - } - - public get tags(): TagsClient { - return (this._tags ??= new TagsClient(this._options)); - } - - public get conversations(): ConversationsClient { - return (this._conversations ??= new ConversationsClient(this._options)); - } - - public get customChannelEvents(): CustomChannelEventsClient { - return (this._customChannelEvents ??= new CustomChannelEventsClient(this._options)); - } - - public get customObjectInstances(): CustomObjectInstancesClient { - return (this._customObjectInstances ??= new CustomObjectInstancesClient(this._options)); - } - - public get dataAttributes(): DataAttributesClient { - return (this._dataAttributes ??= new DataAttributesClient(this._options)); - } - - public get events(): EventsClient { - return (this._events ??= new EventsClient(this._options)); - } - - public get jobs(): JobsClient { - return (this._jobs ??= new JobsClient(this._options)); - } - - public get messages(): MessagesClient { - return (this._messages ??= new MessagesClient(this._options)); - } - - public get segments(): SegmentsClient { - return (this._segments ??= new SegmentsClient(this._options)); - } - - public get subscriptionTypes(): SubscriptionTypesClient { - return (this._subscriptionTypes ??= new SubscriptionTypesClient(this._options)); - } - - public get phoneCallRedirects(): PhoneCallRedirectsClient { - return (this._phoneCallRedirects ??= new PhoneCallRedirectsClient(this._options)); - } - - public get calls(): CallsClient { - return (this._calls ??= new CallsClient(this._options)); - } - - public get teams(): TeamsClient { - return (this._teams ??= new TeamsClient(this._options)); - } - - public get ticketStates(): TicketStatesClient { - return (this._ticketStates ??= new TicketStatesClient(this._options)); - } - - public get ticketTypes(): TicketTypesClient { - return (this._ticketTypes ??= new TicketTypesClient(this._options)); - } - - public get tickets(): TicketsClient { - return (this._tickets ??= new TicketsClient(this._options)); - } - - public get visitors(): VisitorsClient { - return (this._visitors ??= new VisitorsClient(this._options)); - } - - public get news(): NewsClient { - return (this._news ??= new NewsClient(this._options)); - } - - public get unstable(): UnstableClient { - return (this._unstable ??= new UnstableClient(this._options)); - } -} diff --git a/src/_shims/MultipartBody.ts b/src/_shims/MultipartBody.ts new file mode 100644 index 00000000..af3b1118 --- /dev/null +++ b/src/_shims/MultipartBody.ts @@ -0,0 +1,9 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export class MultipartBody { + constructor(public body: any) {} + get [Symbol.toStringTag](): string { + return 'MultipartBody'; + } +} diff --git a/src/_shims/README.md b/src/_shims/README.md new file mode 100644 index 00000000..a57c3bb0 --- /dev/null +++ b/src/_shims/README.md @@ -0,0 +1,46 @@ +# 👋 Wondering what everything in here does? + +`intercom-client` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various +edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM). + +To do this, `intercom-client` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node. + +It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to +automatically select the correct shims for each environment. However, conditional exports are a fairly new +feature and not supported everywhere. For instance, the TypeScript `"moduleResolution": "node"` + +setting doesn't consult the `exports` map, compared to `"moduleResolution": "nodeNext"`, which does. +Unfortunately that's still the default setting, and it can result in errors like +getting the wrong raw `Response` type from `.asResponse()`, for example. + +The user can work around these issues by manually importing one of: + +- `import 'intercom-client/shims/node'` +- `import 'intercom-client/shims/web'` + +All of the code here in `_shims` handles selecting the automatic default shims or manual overrides. + +### How it works - Runtime + +Runtime shims get installed by calling `setShims` exported by `intercom-client/_shims/registry`. + +Manually importing `intercom-client/shims/node` or `intercom-client/shims/web`, calls `setShims` with the respective runtime shims. + +All client code imports shims from `intercom-client/_shims/index`, which: + +- checks if shims have been set manually +- if not, calls `setShims` with the shims from `intercom-client/_shims/auto/runtime` +- re-exports the installed shims from `intercom-client/_shims/registry`. + +`intercom-client/_shims/auto/runtime` exports web runtime shims. +If the `node` export condition is set, the export map replaces it with `intercom-client/_shims/auto/runtime-node`. + +### How it works - Type time + +All client code imports shim types from `intercom-client/_shims/index`, which selects the manual types from `intercom-client/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `intercom-client/_shims/auto/types`. + +`intercom-client/_shims/manual-types` exports an empty namespace. +Manually importing `intercom-client/shims/node` or `intercom-client/shims/web` merges declarations into this empty namespace, so they get picked up by `intercom-client/_shims/index`. + +`intercom-client/_shims/auto/types` exports web type definitions. +If the `node` export condition is set, the export map replaces it with `intercom-client/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`. diff --git a/src/_shims/auto/runtime-bun.ts b/src/_shims/auto/runtime-bun.ts new file mode 100644 index 00000000..e053254b --- /dev/null +++ b/src/_shims/auto/runtime-bun.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../bun-runtime'; diff --git a/src/_shims/auto/runtime-deno.ts b/src/_shims/auto/runtime-deno.ts new file mode 100644 index 00000000..62b7a39e --- /dev/null +++ b/src/_shims/auto/runtime-deno.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../web-runtime'; diff --git a/src/_shims/auto/runtime-node.ts b/src/_shims/auto/runtime-node.ts new file mode 100644 index 00000000..0ae2216f --- /dev/null +++ b/src/_shims/auto/runtime-node.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../node-runtime'; diff --git a/src/_shims/auto/runtime.ts b/src/_shims/auto/runtime.ts new file mode 100644 index 00000000..62b7a39e --- /dev/null +++ b/src/_shims/auto/runtime.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../web-runtime'; diff --git a/src/_shims/auto/types-deno.ts b/src/_shims/auto/types-deno.ts new file mode 100644 index 00000000..226fb15a --- /dev/null +++ b/src/_shims/auto/types-deno.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../web-types'; diff --git a/src/_shims/auto/types-node.ts b/src/_shims/auto/types-node.ts new file mode 100644 index 00000000..2625a8b7 --- /dev/null +++ b/src/_shims/auto/types-node.ts @@ -0,0 +1,4 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export * from '../node-types'; diff --git a/src/_shims/auto/types.d.ts b/src/_shims/auto/types.d.ts new file mode 100644 index 00000000..d7755070 --- /dev/null +++ b/src/_shims/auto/types.d.ts @@ -0,0 +1,101 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export type Agent = any; + +// @ts-ignore +declare const _fetch: unknown extends typeof fetch ? never : typeof fetch; +export { _fetch as fetch }; + +// @ts-ignore +type _Request = unknown extends Request ? never : Request; +export { _Request as Request }; + +// @ts-ignore +type _RequestInfo = unknown extends RequestInfo ? never : RequestInfo; +export { type _RequestInfo as RequestInfo }; + +// @ts-ignore +type _RequestInit = unknown extends RequestInit ? never : RequestInit; +export { type _RequestInit as RequestInit }; + +// @ts-ignore +type _Response = unknown extends Response ? never : Response; +export { _Response as Response }; + +// @ts-ignore +type _ResponseInit = unknown extends ResponseInit ? never : ResponseInit; +export { type _ResponseInit as ResponseInit }; + +// @ts-ignore +type _ResponseType = unknown extends ResponseType ? never : ResponseType; +export { type _ResponseType as ResponseType }; + +// @ts-ignore +type _BodyInit = unknown extends BodyInit ? never : BodyInit; +export { type _BodyInit as BodyInit }; + +// @ts-ignore +type _Headers = unknown extends Headers ? never : Headers; +export { _Headers as Headers }; + +// @ts-ignore +type _HeadersInit = unknown extends HeadersInit ? never : HeadersInit; +export { type _HeadersInit as HeadersInit }; + +type EndingType = 'native' | 'transparent'; + +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +export type FileFromPathOptions = Omit; + +// @ts-ignore +type _FormData = unknown extends FormData ? never : FormData; +// @ts-ignore +declare const _FormData: unknown extends typeof FormData ? never : typeof FormData; +export { _FormData as FormData }; + +// @ts-ignore +type _File = unknown extends File ? never : File; +// @ts-ignore +declare const _File: unknown extends typeof File ? never : typeof File; +export { _File as File }; + +// @ts-ignore +type _Blob = unknown extends Blob ? never : Blob; +// @ts-ignore +declare const _Blob: unknown extends typeof Blob ? never : typeof Blob; +export { _Blob as Blob }; + +export declare class Readable { + readable: boolean; + readonly readableEnded: boolean; + readonly readableFlowing: boolean | null; + readonly readableHighWaterMark: number; + readonly readableLength: number; + readonly readableObjectMode: boolean; + destroyed: boolean; + read(size?: number): any; + pause(): this; + resume(): this; + isPaused(): boolean; + destroy(error?: Error): this; + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +export declare class FsReadStream extends Readable { + path: {}; // node type is string | Buffer +} + +// @ts-ignore +type _ReadableStream = unknown extends ReadableStream ? never : ReadableStream; +// @ts-ignore +declare const _ReadableStream: unknown extends typeof ReadableStream ? never : typeof ReadableStream; +export { _ReadableStream as ReadableStream }; diff --git a/src/_shims/auto/types.js b/src/_shims/auto/types.js new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/auto/types.js @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/auto/types.mjs b/src/_shims/auto/types.mjs new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/auto/types.mjs @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/bun-runtime.ts b/src/_shims/bun-runtime.ts new file mode 100644 index 00000000..8d5aaab0 --- /dev/null +++ b/src/_shims/bun-runtime.ts @@ -0,0 +1,14 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import { type Shims } from './registry'; +import { getRuntime as getWebRuntime } from './web-runtime'; +import { ReadStream as FsReadStream } from 'node:fs'; + +export function getRuntime(): Shims { + const runtime = getWebRuntime(); + function isFsReadStream(value: any): value is FsReadStream { + return value instanceof FsReadStream; + } + return { ...runtime, isFsReadStream }; +} diff --git a/src/_shims/index-deno.ts b/src/_shims/index-deno.ts new file mode 100644 index 00000000..a6142dca --- /dev/null +++ b/src/_shims/index-deno.ts @@ -0,0 +1,110 @@ +import { MultipartBody } from './MultipartBody'; +import { type RequestOptions } from '../core'; + +export const kind: string = 'web'; + +export type Agent = any; + +const _fetch = fetch; +type _fetch = typeof fetch; +export { _fetch as fetch }; + +const _Request = Request; +type _Request = Request; +export { _Request as Request }; + +type _RequestInfo = RequestInfo; +export { type _RequestInfo as RequestInfo }; + +type _RequestInit = RequestInit; +export { type _RequestInit as RequestInit }; + +const _Response = Response; +type _Response = Response; +export { _Response as Response }; + +type _ResponseInit = ResponseInit; +export { type _ResponseInit as ResponseInit }; + +type _ResponseType = ResponseType; +export { type _ResponseType as ResponseType }; + +type _BodyInit = BodyInit; +export { type _BodyInit as BodyInit }; + +const _Headers = Headers; +type _Headers = Headers; +export { _Headers as Headers }; + +type _HeadersInit = HeadersInit; +export { type _HeadersInit as HeadersInit }; + +type EndingType = 'native' | 'transparent'; + +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +export type FileFromPathOptions = Omit; + +const _FormData = FormData; +type _FormData = FormData; +export { _FormData as FormData }; + +const _File = File; +type _File = File; +export { _File as File }; + +const _Blob = Blob; +type _Blob = Blob; +export { _Blob as Blob }; + +export async function getMultipartRequestOptions>( + form: FormData, + opts: RequestOptions, +): Promise> { + return { + ...opts, + body: new MultipartBody(form) as any, + }; +} + +export function getDefaultAgent(url: string) { + return undefined; +} +export function fileFromPath() { + throw new Error( + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/intercom/intercom-node#file-uploads', + ); +} + +export const isFsReadStream = (value: any) => false; + +export declare class Readable { + readable: boolean; + readonly readableEnded: boolean; + readonly readableFlowing: boolean | null; + readonly readableHighWaterMark: number; + readonly readableLength: number; + readonly readableObjectMode: boolean; + destroyed: boolean; + read(size?: number): any; + pause(): this; + resume(): this; + isPaused(): boolean; + destroy(error?: Error): this; + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +export declare class FsReadStream extends Readable { + path: {}; // node type is string | Buffer +} + +const _ReadableStream = ReadableStream; +type _ReadableStream = ReadableStream; +export { _ReadableStream as ReadableStream }; diff --git a/src/_shims/index.d.ts b/src/_shims/index.d.ts new file mode 100644 index 00000000..52431a29 --- /dev/null +++ b/src/_shims/index.d.ts @@ -0,0 +1,81 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import { manual } from './manual-types'; +import * as auto from 'intercom-client/_shims/auto/types'; +import { type RequestOptions } from '../core'; + +type SelectType = unknown extends Manual ? Auto : Manual; + +export const kind: string; + +// @ts-ignore +export type Agent = SelectType; + +// @ts-ignore +export const fetch: SelectType; + +// @ts-ignore +export type Request = SelectType; +// @ts-ignore +export type RequestInfo = SelectType; +// @ts-ignore +export type RequestInit = SelectType; + +// @ts-ignore +export type Response = SelectType; +// @ts-ignore +export type ResponseInit = SelectType; +// @ts-ignore +export type ResponseType = SelectType; +// @ts-ignore +export type BodyInit = SelectType; +// @ts-ignore +export type Headers = SelectType; +// @ts-ignore +export const Headers: SelectType; +// @ts-ignore +export type HeadersInit = SelectType; + +// @ts-ignore +export type BlobPropertyBag = SelectType; +// @ts-ignore +export type FilePropertyBag = SelectType; +// @ts-ignore +export type FileFromPathOptions = SelectType; +// @ts-ignore +export type FormData = SelectType; +// @ts-ignore +export const FormData: SelectType; +// @ts-ignore +export type File = SelectType; +// @ts-ignore +export const File: SelectType; +// @ts-ignore +export type Blob = SelectType; +// @ts-ignore +export const Blob: SelectType; + +// @ts-ignore +export type Readable = SelectType; +// @ts-ignore +export type FsReadStream = SelectType; +// @ts-ignore +export type ReadableStream = SelectType; +// @ts-ignore +export const ReadableStream: SelectType; + +export function getMultipartRequestOptions>( + form: FormData, + opts: RequestOptions, +): Promise>; + +export function getDefaultAgent(url: string): any; + +// @ts-ignore +export type FileFromPathOptions = SelectType; + +export function fileFromPath(path: string, options?: FileFromPathOptions): Promise; +export function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise; + +export function isFsReadStream(value: any): value is FsReadStream; diff --git a/src/_shims/index.js b/src/_shims/index.js new file mode 100644 index 00000000..3e08c58a --- /dev/null +++ b/src/_shims/index.js @@ -0,0 +1,13 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +const shims = require('./registry'); +const auto = require('intercom-client/_shims/auto/runtime'); +if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); +for (const property of Object.keys(shims)) { + Object.defineProperty(exports, property, { + get() { + return shims[property]; + }, + }); +} diff --git a/src/_shims/index.mjs b/src/_shims/index.mjs new file mode 100644 index 00000000..fa532b12 --- /dev/null +++ b/src/_shims/index.mjs @@ -0,0 +1,7 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import * as shims from './registry.mjs'; +import * as auto from 'intercom-client/_shims/auto/runtime'; +if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true }); +export * from './registry.mjs'; diff --git a/src/_shims/manual-types.d.ts b/src/_shims/manual-types.d.ts new file mode 100644 index 00000000..716c53e3 --- /dev/null +++ b/src/_shims/manual-types.d.ts @@ -0,0 +1,12 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +/** + * Types will get added to this namespace when you import one of the following: + * + * import 'intercom-client/shims/node' + * import 'intercom-client/shims/web' + * + * Importing more than one will cause type and runtime errors. + */ +export namespace manual {} diff --git a/src/_shims/manual-types.js b/src/_shims/manual-types.js new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/manual-types.js @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/manual-types.mjs b/src/_shims/manual-types.mjs new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/manual-types.mjs @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/node-runtime.ts b/src/_shims/node-runtime.ts new file mode 100644 index 00000000..ab9f2ab5 --- /dev/null +++ b/src/_shims/node-runtime.ts @@ -0,0 +1,81 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import * as nf from 'node-fetch'; +import * as fd from 'formdata-node'; +import { type File, type FilePropertyBag } from 'formdata-node'; +import KeepAliveAgent from 'agentkeepalive'; +import { AbortController as AbortControllerPolyfill } from 'abort-controller'; +import { ReadStream as FsReadStream } from 'node:fs'; +import { type Agent } from 'node:http'; +import { FormDataEncoder } from 'form-data-encoder'; +import { Readable } from 'node:stream'; +import { type RequestOptions } from '../core'; +import { MultipartBody } from './MultipartBody'; +import { type Shims } from './registry'; +import { ReadableStream } from 'node:stream/web'; + +type FileFromPathOptions = Omit; + +let fileFromPathWarned = false; + +/** + * @deprecated use fs.createReadStream('./my/file.txt') instead + */ +async function fileFromPath(path: string): Promise; +async function fileFromPath(path: string, filename?: string): Promise; +async function fileFromPath(path: string, options?: FileFromPathOptions): Promise; +async function fileFromPath(path: string, filename?: string, options?: FileFromPathOptions): Promise; +async function fileFromPath(path: string, ...args: any[]): Promise { + // this import fails in environments that don't handle export maps correctly, like old versions of Jest + const { fileFromPath: _fileFromPath } = await import('formdata-node/file-from-path'); + + if (!fileFromPathWarned) { + console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path)}) instead`); + fileFromPathWarned = true; + } + // @ts-ignore + return await _fileFromPath(path, ...args); +} + +const defaultHttpAgent: Agent = new KeepAliveAgent({ keepAlive: true, timeout: 5 * 60 * 1000 }); +const defaultHttpsAgent: Agent = new KeepAliveAgent.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1000 }); + +async function getMultipartRequestOptions>( + form: fd.FormData, + opts: RequestOptions, +): Promise> { + const encoder = new FormDataEncoder(form); + const readable = Readable.from(encoder); + const body = new MultipartBody(readable); + const headers = { + ...opts.headers, + ...encoder.headers, + 'Content-Length': encoder.contentLength, + }; + + return { ...opts, body: body as any, headers }; +} + +export function getRuntime(): Shims { + // Polyfill global object if needed. + if (typeof AbortController === 'undefined') { + // @ts-expect-error (the types are subtly different, but compatible in practice) + globalThis.AbortController = AbortControllerPolyfill; + } + return { + kind: 'node', + fetch: nf.default, + Request: nf.Request, + Response: nf.Response, + Headers: nf.Headers, + FormData: fd.FormData, + Blob: fd.Blob, + File: fd.File, + ReadableStream, + getMultipartRequestOptions, + getDefaultAgent: (url: string): Agent => (url.startsWith('https') ? defaultHttpsAgent : defaultHttpAgent), + fileFromPath, + isFsReadStream: (value: any): value is FsReadStream => value instanceof FsReadStream, + }; +} diff --git a/src/_shims/node-types.d.ts b/src/_shims/node-types.d.ts new file mode 100644 index 00000000..b31698f7 --- /dev/null +++ b/src/_shims/node-types.d.ts @@ -0,0 +1,42 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import * as nf from 'node-fetch'; +import * as fd from 'formdata-node'; + +export { type Agent } from 'node:http'; +export { type Readable } from 'node:stream'; +export { type ReadStream as FsReadStream } from 'node:fs'; +export { ReadableStream } from 'web-streams-polyfill'; + +export const fetch: typeof nf.default; + +export type Request = nf.Request; +export type RequestInfo = nf.RequestInfo; +export type RequestInit = nf.RequestInit; + +export type Response = nf.Response; +export type ResponseInit = nf.ResponseInit; +export type ResponseType = nf.ResponseType; +export type BodyInit = nf.BodyInit; +export type Headers = nf.Headers; +export type HeadersInit = nf.HeadersInit; + +type EndingType = 'native' | 'transparent'; +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +export type FileFromPathOptions = Omit; + +export type FormData = fd.FormData; +export const FormData: typeof fd.FormData; +export type File = fd.File; +export const File: typeof fd.File; +export type Blob = fd.Blob; +export const Blob: typeof fd.Blob; diff --git a/src/_shims/node-types.js b/src/_shims/node-types.js new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/node-types.js @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/node-types.mjs b/src/_shims/node-types.mjs new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/node-types.mjs @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/registry.ts b/src/_shims/registry.ts new file mode 100644 index 00000000..87167661 --- /dev/null +++ b/src/_shims/registry.ts @@ -0,0 +1,67 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import { type RequestOptions } from '../core'; + +export interface Shims { + kind: string; + fetch: any; + Request: any; + Response: any; + Headers: any; + FormData: any; + Blob: any; + File: any; + ReadableStream: any; + getMultipartRequestOptions: >( + form: Shims['FormData'], + opts: RequestOptions, + ) => Promise>; + getDefaultAgent: (url: string) => any; + fileFromPath: + | ((path: string, filename?: string, options?: {}) => Promise) + | ((path: string, options?: {}) => Promise); + isFsReadStream: (value: any) => boolean; +} + +export let auto = false; +export let kind: Shims['kind'] | undefined = undefined; +export let fetch: Shims['fetch'] | undefined = undefined; +export let Request: Shims['Request'] | undefined = undefined; +export let Response: Shims['Response'] | undefined = undefined; +export let Headers: Shims['Headers'] | undefined = undefined; +export let FormData: Shims['FormData'] | undefined = undefined; +export let Blob: Shims['Blob'] | undefined = undefined; +export let File: Shims['File'] | undefined = undefined; +export let ReadableStream: Shims['ReadableStream'] | undefined = undefined; +export let getMultipartRequestOptions: Shims['getMultipartRequestOptions'] | undefined = undefined; +export let getDefaultAgent: Shims['getDefaultAgent'] | undefined = undefined; +export let fileFromPath: Shims['fileFromPath'] | undefined = undefined; +export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined; + +export function setShims(shims: Shims, options: { auto: boolean } = { auto: false }) { + if (auto) { + throw new Error( + `you must \`import 'intercom-client/shims/${shims.kind}'\` before importing anything else from intercom-client`, + ); + } + if (kind) { + throw new Error( + `can't \`import 'intercom-client/shims/${shims.kind}'\` after \`import 'intercom-client/shims/${kind}'\``, + ); + } + auto = options.auto; + kind = shims.kind; + fetch = shims.fetch; + Request = shims.Request; + Response = shims.Response; + Headers = shims.Headers; + FormData = shims.FormData; + Blob = shims.Blob; + File = shims.File; + ReadableStream = shims.ReadableStream; + getMultipartRequestOptions = shims.getMultipartRequestOptions; + getDefaultAgent = shims.getDefaultAgent; + fileFromPath = shims.fileFromPath; + isFsReadStream = shims.isFsReadStream; +} diff --git a/src/_shims/web-runtime.ts b/src/_shims/web-runtime.ts new file mode 100644 index 00000000..10dd5fe5 --- /dev/null +++ b/src/_shims/web-runtime.ts @@ -0,0 +1,103 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +import { MultipartBody } from './MultipartBody'; +import { type RequestOptions } from '../core'; +import { type Shims } from './registry'; + +export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } = {}): Shims { + const recommendation = + manuallyImported ? + `You may need to use polyfills` + : `Add one of these imports before your first \`import … from 'intercom-client'\`: +- \`import 'intercom-client/shims/node'\` (if you're running on Node) +- \`import 'intercom-client/shims/web'\` (otherwise) +`; + + let _fetch, _Request, _Response, _Headers; + try { + // @ts-ignore + _fetch = fetch; + // @ts-ignore + _Request = Request; + // @ts-ignore + _Response = Response; + // @ts-ignore + _Headers = Headers; + } catch (error) { + throw new Error( + `this environment is missing the following Web Fetch API type: ${ + (error as any).message + }. ${recommendation}`, + ); + } + + return { + kind: 'web', + fetch: _fetch, + Request: _Request, + Response: _Response, + Headers: _Headers, + FormData: + // @ts-ignore + typeof FormData !== 'undefined' ? FormData : ( + class FormData { + // @ts-ignore + constructor() { + throw new Error( + `file uploads aren't supported in this environment yet as 'FormData' is undefined. ${recommendation}`, + ); + } + } + ), + Blob: + typeof Blob !== 'undefined' ? Blob : ( + class Blob { + constructor() { + throw new Error( + `file uploads aren't supported in this environment yet as 'Blob' is undefined. ${recommendation}`, + ); + } + } + ), + File: + // @ts-ignore + typeof File !== 'undefined' ? File : ( + class File { + // @ts-ignore + constructor() { + throw new Error( + `file uploads aren't supported in this environment yet as 'File' is undefined. ${recommendation}`, + ); + } + } + ), + ReadableStream: + // @ts-ignore + typeof ReadableStream !== 'undefined' ? ReadableStream : ( + class ReadableStream { + // @ts-ignore + constructor() { + throw new Error( + `streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${recommendation}`, + ); + } + } + ), + getMultipartRequestOptions: async >( + // @ts-ignore + form: FormData, + opts: RequestOptions, + ): Promise> => ({ + ...opts, + body: new MultipartBody(form) as any, + }), + getDefaultAgent: (url: string) => undefined, + fileFromPath: () => { + throw new Error( + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/intercom/intercom-node#file-uploads', + ); + }, + isFsReadStream: (value: any) => false, + }; +} diff --git a/src/_shims/web-types.d.ts b/src/_shims/web-types.d.ts new file mode 100644 index 00000000..4ff35138 --- /dev/null +++ b/src/_shims/web-types.d.ts @@ -0,0 +1,83 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ +export type Agent = any; + +declare const _fetch: typeof fetch; +export { _fetch as fetch }; + +type _Request = Request; +export { _Request as Request }; + +type _RequestInfo = RequestInfo; +export { type _RequestInfo as RequestInfo }; + +type _RequestInit = RequestInit; +export { type _RequestInit as RequestInit }; + +type _Response = Response; +export { _Response as Response }; + +type _ResponseInit = ResponseInit; +export { type _ResponseInit as ResponseInit }; + +type _ResponseType = ResponseType; +export { type _ResponseType as ResponseType }; + +type _BodyInit = BodyInit; +export { type _BodyInit as BodyInit }; + +type _Headers = Headers; +export { _Headers as Headers }; + +type _HeadersInit = HeadersInit; +export { type _HeadersInit as HeadersInit }; + +type EndingType = 'native' | 'transparent'; + +export interface BlobPropertyBag { + endings?: EndingType; + type?: string; +} + +export interface FilePropertyBag extends BlobPropertyBag { + lastModified?: number; +} + +export type FileFromPathOptions = Omit; + +type _FormData = FormData; +declare const _FormData: typeof FormData; +export { _FormData as FormData }; + +type _File = File; +declare const _File: typeof File; +export { _File as File }; + +type _Blob = Blob; +declare const _Blob: typeof Blob; +export { _Blob as Blob }; + +export declare class Readable { + readable: boolean; + readonly readableEnded: boolean; + readonly readableFlowing: boolean | null; + readonly readableHighWaterMark: number; + readonly readableLength: number; + readonly readableObjectMode: boolean; + destroyed: boolean; + read(size?: number): any; + pause(): this; + resume(): this; + isPaused(): boolean; + destroy(error?: Error): this; + [Symbol.asyncIterator](): AsyncIterableIterator; +} + +export declare class FsReadStream extends Readable { + path: {}; // node type is string | Buffer +} + +type _ReadableStream = ReadableStream; +declare const _ReadableStream: typeof ReadableStream; +export { _ReadableStream as ReadableStream }; diff --git a/src/_shims/web-types.js b/src/_shims/web-types.js new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/web-types.js @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/_shims/web-types.mjs b/src/_shims/web-types.mjs new file mode 100644 index 00000000..ddbdb799 --- /dev/null +++ b/src/_shims/web-types.mjs @@ -0,0 +1,3 @@ +/** + * Disclaimer: modules in _shims aren't intended to be imported by SDK users. + */ diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts deleted file mode 100644 index 90b9567c..00000000 --- a/src/api/errors/BadRequestError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; - -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/errors/ForbiddenError.ts b/src/api/errors/ForbiddenError.ts deleted file mode 100644 index 3d3e38f8..00000000 --- a/src/api/errors/ForbiddenError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; -import type * as Intercom from "../index.js"; - -export class ForbiddenError extends errors.IntercomError { - 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 deleted file mode 100644 index e097f867..00000000 --- a/src/api/errors/NotFoundError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; - -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/errors/TooManyRequestsError.ts b/src/api/errors/TooManyRequestsError.ts deleted file mode 100644 index 713f4ece..00000000 --- a/src/api/errors/TooManyRequestsError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; -import type * as Intercom from "../index.js"; - -export class TooManyRequestsError extends errors.IntercomError { - constructor(body: Intercom.Error_, rawResponse?: core.RawResponse) { - super({ - message: "TooManyRequestsError", - statusCode: 429, - body: body, - rawResponse: rawResponse, - }); - Object.setPrototypeOf(this, TooManyRequestsError.prototype); - } -} diff --git a/src/api/errors/UnauthorizedError.ts b/src/api/errors/UnauthorizedError.ts deleted file mode 100644 index 16bbd3af..00000000 --- a/src/api/errors/UnauthorizedError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; -import type * as Intercom from "../index.js"; - -export class UnauthorizedError extends errors.IntercomError { - 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 deleted file mode 100644 index ab175870..00000000 --- a/src/api/errors/UnprocessableEntityError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../core/index.js"; -import * as errors from "../../errors/index.js"; - -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/errors/index.ts b/src/api/errors/index.ts deleted file mode 100644 index a8a67c9f..00000000 --- a/src/api/errors/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./BadRequestError.js"; -export * from "./ForbiddenError.js"; -export * from "./NotFoundError.js"; -export * from "./TooManyRequestsError.js"; -export * from "./UnauthorizedError.js"; -export * from "./UnprocessableEntityError.js"; diff --git a/src/api/index.ts b/src/api/index.ts deleted file mode 100644 index f847ea3d..00000000 --- a/src/api/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./errors/index.js"; -export * from "./resources/index.js"; -export * from "./types/index.js"; -export type { IntercomVersion } from "./version.js"; diff --git a/src/api/resources/admins/client/Client.ts b/src/api/resources/admins/client/Client.ts deleted file mode 100644 index f836356f..00000000 --- a/src/api/resources/admins/client/Client.ts +++ /dev/null @@ -1,392 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace AdminsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Admins - */ -export class AdminsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AdminsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.admins.identify() - */ - public identify( - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__identify(requestOptions)); - } - - private async __identify( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "me", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/me"); - } - - /** - * You can set an Admin as away for the Inbox. - * - * @param {Intercom.ConfigureAwayAdminRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.admins.away({ - * admin_id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true, - * away_status_reason_id: 12345 - * }) - * - * @example - * await client.admins.away({ - * admin_id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true - * }) - */ - public away( - request: Intercom.ConfigureAwayAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__away(request, requestOptions)); - } - - private async __away( - request: Intercom.ConfigureAwayAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { admin_id: adminId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(adminId)}/away`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Admin | 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/admins/{admin_id}/away"); - } - - /** - * You can get a log of activities by all admins in an app. - * - * @param {Intercom.ListAllActivityLogsRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.admins.listAllActivityLogs({ - * created_at_after: "1677253093", - * created_at_before: "1677861493" - * }) - */ - public listAllActivityLogs( - request: Intercom.ListAllActivityLogsRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAllActivityLogs(request, requestOptions)); - } - - private async __listAllActivityLogs( - request: Intercom.ListAllActivityLogsRequest, - requestOptions?: AdminsClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "admins/activity_logs", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/activity_logs"); - } - - /** - * You can fetch a list of admins for a given workspace. - * - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.admins.list() - */ - public list(requestOptions?: AdminsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "admins", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins"); - } - - /** - * You can retrieve the details of a single admin. - * - * @param {Intercom.FindAdminRequest} request - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.admins.find({ - * admin_id: 1 - * }) - */ - public find( - request: Intercom.FindAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { admin_id: adminId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(adminId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Admin | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/{admin_id}"); - } -} diff --git a/src/api/resources/admins/client/index.ts b/src/api/resources/admins/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/admins/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/admins/client/requests/ConfigureAwayAdminRequest.ts b/src/api/resources/admins/client/requests/ConfigureAwayAdminRequest.ts deleted file mode 100644 index 0e21602b..00000000 --- a/src/api/resources/admins/client/requests/ConfigureAwayAdminRequest.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * admin_id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true, - * away_status_reason_id: 12345 - * } - * - * @example - * { - * admin_id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true - * } - * - * @example - * { - * admin_id: 1, - * away_mode_enabled: true, - * away_mode_reassign: true - * } - */ -export interface ConfigureAwayAdminRequest { - /** The unique identifier of a given admin */ - 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/admins/client/requests/FindAdminRequest.ts b/src/api/resources/admins/client/requests/FindAdminRequest.ts deleted file mode 100644 index 46f8a13f..00000000 --- a/src/api/resources/admins/client/requests/FindAdminRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * admin_id: 1 - * } - */ -export interface FindAdminRequest { - /** The unique identifier of a given admin */ - admin_id: number; -} diff --git a/src/api/resources/admins/client/requests/ListAllActivityLogsRequest.ts b/src/api/resources/admins/client/requests/ListAllActivityLogsRequest.ts deleted file mode 100644 index b52e406b..00000000 --- a/src/api/resources/admins/client/requests/ListAllActivityLogsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * created_at_after: "1677253093", - * created_at_before: "1677861493" - * } - */ -export interface ListAllActivityLogsRequest { - /** 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/admins/client/requests/index.ts b/src/api/resources/admins/client/requests/index.ts deleted file mode 100644 index 9d853cb4..00000000 --- a/src/api/resources/admins/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { ConfigureAwayAdminRequest } from "./ConfigureAwayAdminRequest.js"; -export type { FindAdminRequest } from "./FindAdminRequest.js"; -export type { ListAllActivityLogsRequest } from "./ListAllActivityLogsRequest.js"; diff --git a/src/api/resources/admins/index.ts b/src/api/resources/admins/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/admins/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/admins/types/Admin.ts b/src/api/resources/admins/types/Admin.ts deleted file mode 100644 index 957fee42..00000000 --- a/src/api/resources/admins/types/Admin.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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[]; - /** The avatar object associated with the admin */ - avatar?: Admin.Avatar; - team_priority_level?: Intercom.TeamPriorityLevel; -} - -export namespace Admin { - /** - * The avatar object associated with the admin - */ - export interface Avatar { - /** URL of the admin's avatar image */ - image_url: string; - } -} diff --git a/src/api/resources/admins/types/index.ts b/src/api/resources/admins/types/index.ts deleted file mode 100644 index 838f94f4..00000000 --- a/src/api/resources/admins/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Admin.js"; diff --git a/src/api/resources/aiAgent/index.ts b/src/api/resources/aiAgent/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/aiAgent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/aiAgent/types/AiAgent.ts b/src/api/resources/aiAgent/types/AiAgent.ts deleted file mode 100644 index 19ae094e..00000000 --- a/src/api/resources/aiAgent/types/AiAgent.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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?: AiAgent.LastAnswerType; - /** The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ - resolution_state?: AiAgent.ResolutionState; - /** 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; - /** The time when the AI agent rating was created. */ - created_at?: number; - /** The time when the AI agent rating was last updated. */ - updated_at?: number; - content_sources?: Intercom.ContentSourcesList; -} - -export namespace AiAgent { - /** The type of the source that triggered AI Agent involvement in the conversation. */ - export const SourceType = { - EssentialsPlanSetup: "essentials_plan_setup", - Profile: "profile", - Workflow: "workflow", - WorkflowPreview: "workflow_preview", - FinPreview: "fin_preview", - } as const; - export type SourceType = (typeof SourceType)[keyof typeof SourceType]; - /** The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` */ - export const LastAnswerType = { - AiAnswer: "ai_answer", - CustomAnswer: "custom_answer", - } as const; - export type LastAnswerType = (typeof LastAnswerType)[keyof typeof LastAnswerType]; - /** The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ - export const ResolutionState = { - AssumedResolution: "assumed_resolution", - ConfirmedResolution: "confirmed_resolution", - RoutedToTeam: "routed_to_team", - Abandoned: "abandoned", - } as const; - export type ResolutionState = (typeof ResolutionState)[keyof typeof ResolutionState]; -} diff --git a/src/api/resources/aiAgent/types/index.ts b/src/api/resources/aiAgent/types/index.ts deleted file mode 100644 index 27ef772f..00000000 --- a/src/api/resources/aiAgent/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./AiAgent.js"; diff --git a/src/api/resources/aiContent/client/Client.ts b/src/api/resources/aiContent/client/Client.ts deleted file mode 100644 index 2beabc07..00000000 --- a/src/api/resources/aiContent/client/Client.ts +++ /dev/null @@ -1,776 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace AiContentClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * 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 AiContentClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AiContentClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can retrieve a list of all content import sources for a workspace. - * - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.listContentImportSources() - */ - public listContentImportSources( - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listContentImportSources(requestOptions)); - } - - private async __listContentImportSources( - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/content_import_sources", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContentImportSourcesList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/content_import_sources"); - } - - /** - * You can create a new content import source by sending a POST request to this endpoint. - * - * @param {Intercom.CreateContentImportSourceRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.createContentImportSource({ - * url: "https://www.example.com" - * }) - */ - public createContentImportSource( - request: Intercom.CreateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createContentImportSource(request, requestOptions)); - } - - private async __createContentImportSource( - request: Intercom.CreateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/content_import_sources", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ...request, sync_behavior: "api" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContentImportSource, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ai/content_import_sources"); - } - - /** - * @param {Intercom.GetContentImportSourceRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.getContentImportSource({ - * source_id: "source_id" - * }) - */ - public getContentImportSource( - request: Intercom.GetContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getContentImportSource(request, requestOptions)); - } - - private async __getContentImportSource( - request: Intercom.GetContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { source_id: sourceId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(sourceId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContentImportSource, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/ai/content_import_sources/{source_id}", - ); - } - - /** - * You can update an existing content import source. - * - * @param {Intercom.UpdateContentImportSourceRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.updateContentImportSource({ - * source_id: "source_id", - * sync_behavior: "api", - * url: "https://www.example.com" - * }) - */ - public updateContentImportSource( - request: Intercom.UpdateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateContentImportSource(request, requestOptions)); - } - - private async __updateContentImportSource( - request: Intercom.UpdateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { source_id: sourceId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(sourceId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContentImportSource, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/ai/content_import_sources/{source_id}", - ); - } - - /** - * 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.DeleteContentImportSourceRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.deleteContentImportSource({ - * source_id: "source_id" - * }) - */ - public deleteContentImportSource( - request: Intercom.DeleteContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteContentImportSource(request, requestOptions)); - } - - private async __deleteContentImportSource( - request: Intercom.DeleteContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { source_id: sourceId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(sourceId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/ai/content_import_sources/{source_id}", - ); - } - - /** - * You can retrieve a list of all external pages for a workspace. - * - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.listExternalPages() - */ - public listExternalPages( - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listExternalPages(requestOptions)); - } - - private async __listExternalPages( - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/external_pages", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ExternalPagesList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/external_pages"); - } - - /** - * 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.CreateExternalPageRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.createExternalPage({ - * title: "Test", - * html: "

Test

", - * url: "https://www.example.com", - * source_id: 44, - * external_id: "abc1234" - * }) - */ - public createExternalPage( - request: Intercom.CreateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createExternalPage(request, requestOptions)); - } - - private async __createExternalPage( - request: Intercom.CreateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/external_pages", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ...request, locale: "en" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ExternalPage, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ai/external_pages"); - } - - /** - * You can retrieve an external page. - * - * @param {Intercom.GetExternalPageRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.getExternalPage({ - * page_id: "page_id" - * }) - */ - public getExternalPage( - request: Intercom.GetExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getExternalPage(request, requestOptions)); - } - - private async __getExternalPage( - request: Intercom.GetExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { page_id: pageId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(pageId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ExternalPage, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/external_pages/{page_id}"); - } - - /** - * You can update an existing external page (if it was created via the API). - * - * @param {Intercom.UpdateExternalPageRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.updateExternalPage({ - * page_id: "page_id", - * title: "Test", - * html: "

Test

", - * url: "https://www.example.com", - * source_id: 47, - * external_id: "5678" - * }) - */ - public updateExternalPage( - request: Intercom.UpdateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateExternalPage(request, requestOptions)); - } - - private async __updateExternalPage( - request: Intercom.UpdateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { page_id: pageId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(pageId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ..._body, locale: "en" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ExternalPage, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/ai/external_pages/{page_id}"); - } - - /** - * 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.DeleteExternalPageRequest} request - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.aiContent.deleteExternalPage({ - * page_id: "page_id" - * }) - */ - public deleteExternalPage( - request: Intercom.DeleteExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteExternalPage(request, requestOptions)); - } - - private async __deleteExternalPage( - request: Intercom.DeleteExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { page_id: pageId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(pageId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ExternalPage, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/ai/external_pages/{page_id}", - ); - } -} diff --git a/src/api/resources/aiContent/client/index.ts b/src/api/resources/aiContent/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/aiContent/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts b/src/api/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts deleted file mode 100644 index f487b162..00000000 --- a/src/api/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/aiContent/client/requests/CreateExternalPageRequest.ts b/src/api/resources/aiContent/client/requests/CreateExternalPageRequest.ts deleted file mode 100644 index c4f5e914..00000000 --- a/src/api/resources/aiContent/client/requests/CreateExternalPageRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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/aiContent/client/requests/DeleteContentImportSourceRequest.ts b/src/api/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts deleted file mode 100644 index 4e3cd384..00000000 --- a/src/api/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * source_id: "source_id" - * } - */ -export interface DeleteContentImportSourceRequest { - /** The unique identifier for the content import source which is given by Intercom. */ - source_id: string; -} diff --git a/src/api/resources/aiContent/client/requests/DeleteExternalPageRequest.ts b/src/api/resources/aiContent/client/requests/DeleteExternalPageRequest.ts deleted file mode 100644 index 600b878a..00000000 --- a/src/api/resources/aiContent/client/requests/DeleteExternalPageRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page_id: "page_id" - * } - */ -export interface DeleteExternalPageRequest { - /** The unique identifier for the external page which is given by Intercom. */ - page_id: string; -} diff --git a/src/api/resources/aiContent/client/requests/GetContentImportSourceRequest.ts b/src/api/resources/aiContent/client/requests/GetContentImportSourceRequest.ts deleted file mode 100644 index 9fc6e88a..00000000 --- a/src/api/resources/aiContent/client/requests/GetContentImportSourceRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * source_id: "source_id" - * } - */ -export interface GetContentImportSourceRequest { - /** The unique identifier for the content import source which is given by Intercom. */ - source_id: string; -} diff --git a/src/api/resources/aiContent/client/requests/GetExternalPageRequest.ts b/src/api/resources/aiContent/client/requests/GetExternalPageRequest.ts deleted file mode 100644 index 3255d445..00000000 --- a/src/api/resources/aiContent/client/requests/GetExternalPageRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page_id: "page_id" - * } - */ -export interface GetExternalPageRequest { - /** The unique identifier for the external page which is given by Intercom. */ - page_id: string; -} diff --git a/src/api/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts b/src/api/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts deleted file mode 100644 index 4debce37..00000000 --- a/src/api/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * source_id: "source_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. */ - source_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 const SyncBehavior = { - Api: "api", - Automated: "automated", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/aiContent/client/requests/UpdateExternalPageRequest.ts b/src/api/resources/aiContent/client/requests/UpdateExternalPageRequest.ts deleted file mode 100644 index 75d703c3..00000000 --- a/src/api/resources/aiContent/client/requests/UpdateExternalPageRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page_id: "page_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. */ - page_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/aiContent/client/requests/index.ts b/src/api/resources/aiContent/client/requests/index.ts deleted file mode 100644 index 2c010829..00000000 --- a/src/api/resources/aiContent/client/requests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type { CreateContentImportSourceRequest } from "./CreateContentImportSourceRequest.js"; -export type { CreateExternalPageRequest } from "./CreateExternalPageRequest.js"; -export type { DeleteContentImportSourceRequest } from "./DeleteContentImportSourceRequest.js"; -export type { DeleteExternalPageRequest } from "./DeleteExternalPageRequest.js"; -export type { GetContentImportSourceRequest } from "./GetContentImportSourceRequest.js"; -export type { GetExternalPageRequest } from "./GetExternalPageRequest.js"; -export type { UpdateContentImportSourceRequest } from "./UpdateContentImportSourceRequest.js"; -export type { UpdateExternalPageRequest } from "./UpdateExternalPageRequest.js"; diff --git a/src/api/resources/aiContent/index.ts b/src/api/resources/aiContent/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/aiContent/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/aiContent/types/ContentImportSource.ts b/src/api/resources/aiContent/types/ContentImportSource.ts deleted file mode 100644 index e65d8d1a..00000000 --- a/src/api/resources/aiContent/types/ContentImportSource.ts +++ /dev/null @@ -1,39 +0,0 @@ -// 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 const SyncBehavior = { - Api: "api", - Automatic: "automatic", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/aiContent/types/ContentImportSourcesList.ts b/src/api/resources/aiContent/types/ContentImportSourcesList.ts deleted file mode 100644 index 8e7018fe..00000000 --- a/src/api/resources/aiContent/types/ContentImportSourcesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.PagesLink; - /** A count of the total number of content import sources. */ - total_count?: number; - /** An array of Content Import Source objects */ - data?: Intercom.ContentImportSource[]; -} diff --git a/src/api/resources/aiContent/types/ExternalPage.ts b/src/api/resources/aiContent/types/ExternalPage.ts deleted file mode 100644 index 97afb31c..00000000 --- a/src/api/resources/aiContent/types/ExternalPage.ts +++ /dev/null @@ -1,35 +0,0 @@ -// 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/aiContent/types/ExternalPagesList.ts b/src/api/resources/aiContent/types/ExternalPagesList.ts deleted file mode 100644 index ec5273ca..00000000 --- a/src/api/resources/aiContent/types/ExternalPagesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of external pages for the App. - */ -export interface ExternalPagesList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.PagesLink; - /** A count of the total number of external pages. */ - total_count?: number; - /** An array of External Page objects */ - data?: Intercom.ExternalPage[]; -} diff --git a/src/api/resources/aiContent/types/index.ts b/src/api/resources/aiContent/types/index.ts deleted file mode 100644 index 4a084844..00000000 --- a/src/api/resources/aiContent/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./ContentImportSource.js"; -export * from "./ContentImportSourcesList.js"; -export * from "./ExternalPage.js"; -export * from "./ExternalPagesList.js"; diff --git a/src/api/resources/aiContentSource/index.ts b/src/api/resources/aiContentSource/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/aiContentSource/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/aiContentSource/types/ContentSource.ts b/src/api/resources/aiContentSource/types/ContentSource.ts deleted file mode 100644 index 7013e220..00000000 --- a/src/api/resources/aiContentSource/types/ContentSource.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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?: "custom_answer"; - /** 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; -} diff --git a/src/api/resources/aiContentSource/types/index.ts b/src/api/resources/aiContentSource/types/index.ts deleted file mode 100644 index 190780ca..00000000 --- a/src/api/resources/aiContentSource/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ContentSource.js"; diff --git a/src/api/resources/articles/client/Client.ts b/src/api/resources/articles/client/Client.ts deleted file mode 100644 index e101ba3d..00000000 --- a/src/api/resources/articles/client/Client.ts +++ /dev/null @@ -1,532 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace ArticlesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Articles - */ -export class ArticlesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ArticlesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {Intercom.ListArticlesRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.articles.list() - */ - public async list( - request: Intercom.ListArticlesRequest = {}, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles"); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.data ?? []).length > 0, - getItems: (response) => response?.data ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } - - /** - * You can create a new article by making a POST request to `https://api.intercom.io/articles`. - * - * @param {Intercom.CreateArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.articles.create({ - * title: "Thanks for everything", - * description: "Description of the Article", - * body: "Body of the Article", - * author_id: 991267497, - * state: "published", - * parent_id: 145, - * parent_type: "collection", - * translated_content: { - * fr: { - * title: "Merci pour tout", - * description: "Description de l'article", - * body: "Corps de l'article", - * author_id: 991267497, - * state: "published" - * } - * } - * }) - * - * @example - * await client.articles.create({ - * title: "Thanks for everything", - * description: "Description of the Article", - * body: "Body of the Article", - * author_id: 1295, - * state: "published" - * }) - */ - public create( - request?: Intercom.CreateArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request?: Intercom.CreateArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles"); - } - - /** - * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. - * - * @param {Intercom.FindArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.articles.find({ - * article_id: 1 - * }) - */ - public find( - request: Intercom.FindArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { article_id: articleId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(articleId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/{article_id}"); - } - - /** - * You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. - * - * @param {Intercom.UpdateArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.articles.update({ - * article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * }) - */ - public update( - request: Intercom.UpdateArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { article_id: articleId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(articleId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/articles/{article_id}"); - } - - /** - * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. - * - * @param {Intercom.DeleteArticleRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.articles.delete({ - * article_id: 1 - * }) - */ - public delete( - request: Intercom.DeleteArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.DeleteArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { article_id: articleId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(articleId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/articles/{article_id}"); - } - - /** - * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. - * - * @param {Intercom.SearchArticlesRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.articles.search({ - * phrase: "Getting started", - * state: "published", - * help_center_id: 1, - * highlight: true - * }) - */ - public search( - request: Intercom.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__search(request, requestOptions)); - } - - private async __search( - request: Intercom.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles/search", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ArticleSearchResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/search"); - } -} diff --git a/src/api/resources/articles/client/index.ts b/src/api/resources/articles/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/articles/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/articles/client/requests/DeleteArticleRequest.ts b/src/api/resources/articles/client/requests/DeleteArticleRequest.ts deleted file mode 100644 index 43cfd9e2..00000000 --- a/src/api/resources/articles/client/requests/DeleteArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * article_id: 1 - * } - */ -export interface DeleteArticleRequest { - /** The unique identifier for the article which is given by Intercom. */ - article_id: number; -} diff --git a/src/api/resources/articles/client/requests/FindArticleRequest.ts b/src/api/resources/articles/client/requests/FindArticleRequest.ts deleted file mode 100644 index b333b0d8..00000000 --- a/src/api/resources/articles/client/requests/FindArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * article_id: 1 - * } - */ -export interface FindArticleRequest { - /** The unique identifier for the article which is given by Intercom. */ - article_id: number; -} diff --git a/src/api/resources/articles/client/requests/ListArticlesRequest.ts b/src/api/resources/articles/client/requests/ListArticlesRequest.ts deleted file mode 100644 index 598bdacf..00000000 --- a/src/api/resources/articles/client/requests/ListArticlesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * {} - */ -export interface ListArticlesRequest { - /** 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/articles/client/requests/SearchArticlesRequest.ts b/src/api/resources/articles/client/requests/SearchArticlesRequest.ts deleted file mode 100644 index 3416dd98..00000000 --- a/src/api/resources/articles/client/requests/SearchArticlesRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * phrase: "Getting started", - * state: "published", - * help_center_id: 1, - * highlight: true - * } - */ -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/articles/client/requests/UpdateArticleRequest.ts b/src/api/resources/articles/client/requests/UpdateArticleRequest.ts deleted file mode 100644 index 36209811..00000000 --- a/src/api/resources/articles/client/requests/UpdateArticleRequest.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - * - * @example - * { - * article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - */ -export interface UpdateArticleRequest { - /** The unique identifier for the article which is given by Intercom. */ - article_id: number; - /** 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?: UpdateArticleRequest.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.ArticleTranslatedContent; -} - -export namespace UpdateArticleRequest { - /** 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/articles/client/requests/index.ts b/src/api/resources/articles/client/requests/index.ts deleted file mode 100644 index 9376442d..00000000 --- a/src/api/resources/articles/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { DeleteArticleRequest } from "./DeleteArticleRequest.js"; -export type { FindArticleRequest } from "./FindArticleRequest.js"; -export type { ListArticlesRequest } from "./ListArticlesRequest.js"; -export type { SearchArticlesRequest } from "./SearchArticlesRequest.js"; -export type { UpdateArticleRequest } from "./UpdateArticleRequest.js"; diff --git a/src/api/resources/articles/index.ts b/src/api/resources/articles/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/articles/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/articles/types/Article.ts b/src/api/resources/articles/types/Article.ts deleted file mode 100644 index 02667c69..00000000 --- a/src/api/resources/articles/types/Article.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.ArticleListItem { - statistics?: Intercom.ArticleStatistics; -} diff --git a/src/api/resources/articles/types/ArticleListItem.ts b/src/api/resources/articles/types/ArticleListItem.ts deleted file mode 100644 index 426c862a..00000000 --- a/src/api/resources/articles/types/ArticleListItem.ts +++ /dev/null @@ -1,49 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/articles/types/ArticleSearchHighlights.ts deleted file mode 100644 index c80f22fa..00000000 --- a/src/api/resources/articles/types/ArticleSearchHighlights.ts +++ /dev/null @@ -1,61 +0,0 @@ -// 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 const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - 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 const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/articles/types/ArticleSearchResponse.ts deleted file mode 100644 index 349062a8..00000000 --- a/src/api/resources/articles/types/ArticleSearchResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.CursorPages; -} - -export namespace ArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Article objects */ - articles?: Intercom.Article[]; - /** A corresponding array of highlighted Article content */ - highlights?: Intercom.ArticleSearchHighlights[]; - } -} diff --git a/src/api/resources/articles/types/InternalArticle.ts b/src/api/resources/articles/types/InternalArticle.ts deleted file mode 100644 index dec37b5f..00000000 --- a/src/api/resources/articles/types/InternalArticle.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The Internal Articles API is a central place to gather all information and take actions on your internal articles. - */ -export type InternalArticle = Intercom.InternalArticleListItem; diff --git a/src/api/resources/articles/types/index.ts b/src/api/resources/articles/types/index.ts deleted file mode 100644 index ac1a15f9..00000000 --- a/src/api/resources/articles/types/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./Article.js"; -export * from "./ArticleListItem.js"; -export * from "./ArticleSearchHighlights.js"; -export * from "./ArticleSearchResponse.js"; -export * from "./InternalArticle.js"; diff --git a/src/api/resources/awayStatusReasons/client/Client.ts b/src/api/resources/awayStatusReasons/client/Client.ts deleted file mode 100644 index 22df5064..00000000 --- a/src/api/resources/awayStatusReasons/client/Client.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace AwayStatusReasonsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Away Status Reasons - */ -export class AwayStatusReasonsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AwayStatusReasonsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Returns a list of all away status reasons configured for the workspace, including deleted ones. - * - * @param {AwayStatusReasonsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.awayStatusReasons.listAwayStatusReasons() - */ - public listAwayStatusReasons( - requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions)); - } - - private async __listAwayStatusReasons( - requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "away_status_reasons", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.AwayStatusReason[], 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/away_status_reasons"); - } -} diff --git a/src/api/resources/awayStatusReasons/client/index.ts b/src/api/resources/awayStatusReasons/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/awayStatusReasons/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/awayStatusReasons/index.ts b/src/api/resources/awayStatusReasons/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/awayStatusReasons/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/calls/client/Client.ts b/src/api/resources/calls/client/Client.ts deleted file mode 100644 index 956fcfa5..00000000 --- a/src/api/resources/calls/client/Client.ts +++ /dev/null @@ -1,405 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace CallsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Calls - */ -export class CallsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CallsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve a paginated list of calls. - * - * @param {Intercom.ListCallsRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.calls.listCalls({ - * page: 1, - * per_page: 1 - * }) - */ - public listCalls( - request: Intercom.ListCallsRequest = {}, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCalls(request, requestOptions)); - } - - private async __listCalls( - request: Intercom.ListCallsRequest = {}, - requestOptions?: CallsClient.RequestOptions, - ): 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "calls", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.CallList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls"); - } - - /** - * Retrieve a single call by id. - * - * @param {Intercom.ShowCallRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.calls.showCall({ - * call_id: "call_id" - * }) - */ - public showCall( - request: Intercom.ShowCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCall(request, requestOptions)); - } - - private async __showCall( - request: Intercom.ShowCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { call_id: callId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(callId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Call, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}"); - } - - /** - * Redirects to a signed URL for the call's recording if it exists. - * - * @param {Intercom.ShowCallRecordingRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.calls.showCallRecording({ - * call_id: "call_id" - * }) - */ - public showCallRecording( - request: Intercom.ShowCallRecordingRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCallRecording(request, requestOptions)); - } - - private async __showCallRecording( - request: Intercom.ShowCallRecordingRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { call_id: callId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(callId)}/recording`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}/recording"); - } - - /** - * Returns the transcript for the specified call as a downloadable text file. - * - * @param {Intercom.ShowCallTranscriptRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.calls.showCallTranscript({ - * call_id: "call_id" - * }) - */ - public showCallTranscript( - request: Intercom.ShowCallTranscriptRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCallTranscript(request, requestOptions)); - } - - private async __showCallTranscript( - request: Intercom.ShowCallTranscriptRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { call_id: callId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(callId)}/transcript`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - responseType: "text", - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as string, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{call_id}/transcript"); - } - - /** - * Retrieve calls by a list of conversation ids and include transcripts when available. - * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. - * - * @param {Intercom.ListCallsWithTranscriptsRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.calls.listCallsWithTranscripts({ - * conversation_ids: ["64619700005694", "64619700005695"] - * }) - */ - public listCallsWithTranscripts( - request: Intercom.ListCallsWithTranscriptsRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCallsWithTranscripts(request, requestOptions)); - } - - private async __listCallsWithTranscripts( - request: Intercom.ListCallsWithTranscriptsRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "calls/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.ListCallsWithTranscriptsResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/calls/search"); - } -} diff --git a/src/api/resources/calls/client/index.ts b/src/api/resources/calls/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/calls/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/calls/client/requests/ListCallsRequest.ts b/src/api/resources/calls/client/requests/ListCallsRequest.ts deleted file mode 100644 index 74c29012..00000000 --- a/src/api/resources/calls/client/requests/ListCallsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page: 1, - * per_page: 1 - * } - */ -export interface ListCallsRequest { - /** The page of results to fetch. Defaults to first page */ - page?: number; - /** How many results to display per page. Defaults to 25. Max 25. */ - per_page?: number; -} diff --git a/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts b/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts deleted file mode 100644 index 92d644c1..00000000 --- a/src/api/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_ids: ["64619700005694", "64619700005695"] - * } - */ -export interface ListCallsWithTranscriptsRequest { - /** A list of conversation ids to fetch calls for. Maximum 20. */ - conversation_ids: string[]; -} diff --git a/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts b/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts deleted file mode 100644 index 7b9543df..00000000 --- a/src/api/resources/calls/client/requests/ShowCallRecordingRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * call_id: "call_id" - * } - */ -export interface ShowCallRecordingRequest { - /** The id of the call */ - call_id: string; -} diff --git a/src/api/resources/calls/client/requests/ShowCallRequest.ts b/src/api/resources/calls/client/requests/ShowCallRequest.ts deleted file mode 100644 index 52c4cd8c..00000000 --- a/src/api/resources/calls/client/requests/ShowCallRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * call_id: "call_id" - * } - */ -export interface ShowCallRequest { - /** The id of the call to retrieve */ - call_id: string; -} diff --git a/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts b/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts deleted file mode 100644 index 9c2bbe4e..00000000 --- a/src/api/resources/calls/client/requests/ShowCallTranscriptRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * call_id: "call_id" - * } - */ -export interface ShowCallTranscriptRequest { - /** The id of the call */ - call_id: string; -} diff --git a/src/api/resources/calls/client/requests/index.ts b/src/api/resources/calls/client/requests/index.ts deleted file mode 100644 index 08b2eb9c..00000000 --- a/src/api/resources/calls/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { ListCallsRequest } from "./ListCallsRequest.js"; -export type { ListCallsWithTranscriptsRequest } from "./ListCallsWithTranscriptsRequest.js"; -export type { ShowCallRecordingRequest } from "./ShowCallRecordingRequest.js"; -export type { ShowCallRequest } from "./ShowCallRequest.js"; -export type { ShowCallTranscriptRequest } from "./ShowCallTranscriptRequest.js"; diff --git a/src/api/resources/calls/index.ts b/src/api/resources/calls/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/calls/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/calls/types/Call.ts b/src/api/resources/calls/types/Call.ts deleted file mode 100644 index 33b20803..00000000 --- a/src/api/resources/calls/types/Call.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Represents a phone call in Intercom - */ -export interface Call { - /** String representing the object's type. Always has the value `call`. */ - type?: string; - /** The id of the call. */ - id?: string; - /** The id of the conversation associated with the call, if any. */ - conversation_id?: string; - /** The id of the admin associated with the call, if any. */ - admin_id?: string; - /** The id of the contact associated with the call, if any. */ - contact_id?: string; - /** The current state of the call. */ - state?: string; - initiated_at?: Intercom.Datetime; - answered_at?: Intercom.Datetime; - ended_at?: Intercom.Datetime; - created_at?: Intercom.Datetime; - updated_at?: Intercom.Datetime; - /** API URL to download or redirect to the call recording if available. */ - recording_url?: string; - /** API URL to download or redirect to the call transcript if available. */ - transcription_url?: string; - /** The type of call. */ - call_type?: string; - /** The direction of the call. */ - direction?: string; - /** The reason for the call end, if applicable. */ - ended_reason?: string; - /** The phone number involved in the call, in E.164 format. */ - phone?: string; - /** API URL to the AI Agent (Fin) call recording if available. */ - fin_recording_url?: string; - /** API URL to the AI Agent (Fin) call transcript if available. */ - fin_transcription_url?: string; -} diff --git a/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts b/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts deleted file mode 100644 index f37c83bc..00000000 --- a/src/api/resources/calls/types/ListCallsWithTranscriptsResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ListCallsWithTranscriptsResponse { - type?: string; - data?: ListCallsWithTranscriptsResponse.Data.Item[]; -} - -export namespace ListCallsWithTranscriptsResponse { - export type Data = Data.Item[]; - - export namespace Data { - export interface Item extends Intercom.Call { - /** The call transcript if available, otherwise an empty array. */ - transcript?: Record[]; - /** The status of the transcript if available. */ - transcript_status?: string; - } - } -} diff --git a/src/api/resources/calls/types/index.ts b/src/api/resources/calls/types/index.ts deleted file mode 100644 index a7b7c7f7..00000000 --- a/src/api/resources/calls/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Call.js"; -export * from "./ListCallsWithTranscriptsResponse.js"; diff --git a/src/api/resources/companies/client/Client.ts b/src/api/resources/companies/client/Client.ts deleted file mode 100644 index db9cb03e..00000000 --- a/src/api/resources/companies/client/Client.ts +++ /dev/null @@ -1,1004 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace CompaniesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Companies - */ -export class CompaniesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CompaniesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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.RetrieveCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.retrieve({ - * name: "my company", - * company_id: "12345", - * tag_id: "678910", - * segment_id: "98765", - * page: 1, - * per_page: 1 - * }) - */ - public retrieve( - request: Intercom.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieve(request, requestOptions)); - } - - private async __retrieve( - request: Intercom.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies"); - } - - /** - * 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 {Intercom.CreateOrUpdateCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.companies.createOrUpdate({ - * name: "my company", - * company_id: "company_remote_id", - * remote_created_at: 1374138000 - * }) - * - * @example - * await client.companies.createOrUpdate() - */ - public createOrUpdate( - request?: Intercom.CreateOrUpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createOrUpdate(request, requestOptions)); - } - - private async __createOrUpdate( - request?: Intercom.CreateOrUpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies"); - } - - /** - * You can fetch a single company. - * - * @param {Intercom.FindCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.find({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) - */ - public find( - request: Intercom.FindCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { company_id: companyId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(companyId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{company_id}"); - } - - /** - * 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.UpdateCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.update({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - * body: { - * name: "my company", - * website: "http://www.mycompany.com/" - * } - * }) - * - * @example - * await client.companies.update({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - * body: {} - * }) - */ - public update( - request: Intercom.UpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { company_id: companyId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(companyId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body != null ? _body : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/{company_id}"); - } - - /** - * You can delete a single company. - * - * @param {Intercom.DeleteCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.delete({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) - */ - public delete( - request: Intercom.DeleteCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.DeleteCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { company_id: companyId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(companyId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/companies/{company_id}"); - } - - /** - * You can fetch a list of all contacts that belong to a company. - * - * @param {Intercom.ListAttachedContactsRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.listAttachedContacts({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) - */ - public listAttachedContacts( - request: Intercom.ListAttachedContactsRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); - } - - private async __listAttachedContacts( - request: Intercom.ListAttachedContactsRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { company_id: companyId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(companyId)}/contacts`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/companies/{company_id}/contacts", - ); - } - - /** - * You can fetch a list of all segments that belong to a company. - * - * @param {Intercom.ListSegmentsAttachedToCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.listAttachedSegments({ - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) - */ - public listAttachedSegments( - request: Intercom.ListSegmentsAttachedToCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions)); - } - - private async __listAttachedSegments( - request: Intercom.ListSegmentsAttachedToCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { company_id: companyId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(companyId)}/segments`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/companies/{company_id}/segments", - ); - } - - /** - * 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.ListCompaniesRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.companies.list({ - * page: 1, - * per_page: 1, - * order: "desc" - * }) - */ - public async list( - request: Intercom.ListCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/list", - ), - method: "POST", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/list"); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.data ?? []).length > 0, - getItems: (response) => response?.data ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } - - /** - * 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.ScrollCompaniesRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.companies.scroll({ - * scroll_param: "scroll_param" - * }) - */ - public async scroll( - request: Intercom.ScrollCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/scroll", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CompanyScroll | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/scroll"); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.scroll_param != null && - !(typeof response?.scroll_param === "string" && response?.scroll_param === ""), - getItems: (response) => response?.data ?? [], - loadPage: (response) => { - return list(core.setObjectProperty(request, "scroll_param", response?.scroll_param)); - }, - }); - } - - /** - * You can attach a company to a single contact. - * - * @param {Intercom.AttachContactToCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.attachContact({ - * contact_id: "contact_id", - * id: "6762f09a1bb69f9f2193bb34" - * }) - * - * @example - * await client.companies.attachContact({ - * contact_id: "contact_id", - * id: "58a430d35458202d41b1e65b" - * }) - * - * @example - * await client.companies.attachContact({ - * contact_id: "contact_id", - * id: "123" - * }) - */ - public attachContact( - request: Intercom.AttachContactToCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContact(request, requestOptions)); - } - - private async __attachContact( - request: Intercom.AttachContactToCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/companies`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/contacts/{contact_id}/companies", - ); - } - - /** - * You can detach a company from a single contact. - * - * @param {Intercom.DetachContactFromCompanyRequest} request - * @param {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.companies.detachContact({ - * contact_id: "58a430d35458202d41b1e65b", - * company_id: "58a430d35458202d41b1e65b" - * }) - */ - public detachContact( - request: Intercom.DetachContactFromCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContact(request, requestOptions)); - } - - private async __detachContact( - request: Intercom.DetachContactFromCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, company_id: companyId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/companies/${core.url.encodePathParam(companyId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/companies/{company_id}", - ); - } -} diff --git a/src/api/resources/companies/client/index.ts b/src/api/resources/companies/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/companies/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts b/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts deleted file mode 100644 index 95995f1a..00000000 --- a/src/api/resources/companies/client/requests/AttachContactToCompanyRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "contact_id", - * id: "6762f09a1bb69f9f2193bb34" - * } - * - * @example - * { - * contact_id: "contact_id", - * id: "58a430d35458202d41b1e65b" - * } - * - * @example - * { - * contact_id: "contact_id", - * id: "123" - * } - */ -export interface AttachContactToCompanyRequest { - /** 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/companies/client/requests/DeleteCompanyRequest.ts b/src/api/resources/companies/client/requests/DeleteCompanyRequest.ts deleted file mode 100644 index 89d10288..00000000 --- a/src/api/resources/companies/client/requests/DeleteCompanyRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * } - */ -export interface DeleteCompanyRequest { - /** The unique identifier for the company which is given by Intercom */ - company_id: string; -} diff --git a/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts b/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts deleted file mode 100644 index 6b35eccd..00000000 --- a/src/api/resources/companies/client/requests/DetachContactFromCompanyRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "58a430d35458202d41b1e65b", - * company_id: "58a430d35458202d41b1e65b" - * } - */ -export interface DetachContactFromCompanyRequest { - /** 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 */ - company_id: string; -} diff --git a/src/api/resources/companies/client/requests/FindCompanyRequest.ts b/src/api/resources/companies/client/requests/FindCompanyRequest.ts deleted file mode 100644 index 6be81172..00000000 --- a/src/api/resources/companies/client/requests/FindCompanyRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * } - */ -export interface FindCompanyRequest { - /** The unique identifier for the company which is given by Intercom */ - company_id: string; -} diff --git a/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts b/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts deleted file mode 100644 index 544f392f..00000000 --- a/src/api/resources/companies/client/requests/ListAttachedContactsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * } - */ -export interface ListAttachedContactsRequest { - /** The unique identifier for the company which is given by Intercom */ - company_id: string; -} diff --git a/src/api/resources/companies/client/requests/ListCompaniesRequest.ts b/src/api/resources/companies/client/requests/ListCompaniesRequest.ts deleted file mode 100644 index ff355c19..00000000 --- a/src/api/resources/companies/client/requests/ListCompaniesRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page: 1, - * per_page: 1, - * order: "desc" - * } - */ -export interface ListCompaniesRequest { - /** 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/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts b/src/api/resources/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts deleted file mode 100644 index 36c2e57f..00000000 --- a/src/api/resources/companies/client/requests/ListSegmentsAttachedToCompanyRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * } - */ -export interface ListSegmentsAttachedToCompanyRequest { - /** The unique identifier for the company which is given by Intercom */ - company_id: string; -} diff --git a/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts b/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts deleted file mode 100644 index a3314297..00000000 --- a/src/api/resources/companies/client/requests/RetrieveCompanyRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * name: "my company", - * company_id: "12345", - * tag_id: "678910", - * segment_id: "98765", - * page: 1, - * per_page: 1 - * } - */ -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/companies/client/requests/ScrollCompaniesRequest.ts b/src/api/resources/companies/client/requests/ScrollCompaniesRequest.ts deleted file mode 100644 index 56661c7f..00000000 --- a/src/api/resources/companies/client/requests/ScrollCompaniesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * scroll_param: "scroll_param" - * } - */ -export interface ScrollCompaniesRequest { - /** */ - scroll_param?: string; -} diff --git a/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts b/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts deleted file mode 100644 index 6bb331ec..00000000 --- a/src/api/resources/companies/client/requests/UpdateCompanyRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - * body: { - * name: "my company", - * website: "http://www.mycompany.com/" - * } - * } - * - * @example - * { - * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - * body: {} - * } - */ -export interface UpdateCompanyRequest { - /** The unique identifier for the company which is given by Intercom */ - company_id: string; - body?: Intercom.UpdateCompanyRequestBody; -} diff --git a/src/api/resources/companies/client/requests/index.ts b/src/api/resources/companies/client/requests/index.ts deleted file mode 100644 index 3c6204dc..00000000 --- a/src/api/resources/companies/client/requests/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type { AttachContactToCompanyRequest } from "./AttachContactToCompanyRequest.js"; -export type { DeleteCompanyRequest } from "./DeleteCompanyRequest.js"; -export type { DetachContactFromCompanyRequest } from "./DetachContactFromCompanyRequest.js"; -export type { FindCompanyRequest } from "./FindCompanyRequest.js"; -export type { ListAttachedContactsRequest } from "./ListAttachedContactsRequest.js"; -export type { ListCompaniesRequest } from "./ListCompaniesRequest.js"; -export type { ListSegmentsAttachedToCompanyRequest } from "./ListSegmentsAttachedToCompanyRequest.js"; -export type { RetrieveCompanyRequest } from "./RetrieveCompanyRequest.js"; -export type { ScrollCompaniesRequest } from "./ScrollCompaniesRequest.js"; -export type { UpdateCompanyRequest } from "./UpdateCompanyRequest.js"; diff --git a/src/api/resources/companies/index.ts b/src/api/resources/companies/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/companies/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/companies/types/CompaniesRetrieveResponse.ts b/src/api/resources/companies/types/CompaniesRetrieveResponse.ts deleted file mode 100644 index 97513a72..00000000 --- a/src/api/resources/companies/types/CompaniesRetrieveResponse.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type CompaniesRetrieveResponse = - | Intercom.CompaniesRetrieveResponse.Company - | Intercom.CompaniesRetrieveResponse.List; - -export namespace CompaniesRetrieveResponse { - export interface Company extends Intercom.Company { - type: "company"; - } - - export interface List extends Intercom.CompanyList { - type: "list"; - } -} diff --git a/src/api/resources/companies/types/Company.ts b/src/api/resources/companies/types/Company.ts deleted file mode 100644 index cb26b686..00000000 --- a/src/api/resources/companies/types/Company.ts +++ /dev/null @@ -1,75 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.Segment[]; - } -} diff --git a/src/api/resources/companies/types/index.ts b/src/api/resources/companies/types/index.ts deleted file mode 100644 index 7e2092d3..00000000 --- a/src/api/resources/companies/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./CompaniesRetrieveResponse.js"; -export * from "./Company.js"; diff --git a/src/api/resources/contacts/client/Client.ts b/src/api/resources/contacts/client/Client.ts deleted file mode 100644 index f5ec64f4..00000000 --- a/src/api/resources/contacts/client/Client.ts +++ /dev/null @@ -1,1484 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace ContactsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your contacts - */ -export class ContactsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ContactsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of companies that are associated to a contact. - * - * @param {Intercom.ListAttachedCompaniesRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.listAttachedCompanies({ - * contact_id: "63a07ddf05a32042dffac965", - * page: 1, - * per_page: 1 - * }) - */ - public async listAttachedCompanies( - request: Intercom.ListAttachedCompaniesRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/companies`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/companies", - ); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.companies ?? []).length > 0, - getItems: (response) => response?.companies ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } - - /** - * You can fetch a list of segments that are associated to a contact. - * - * @param {Intercom.ListSegmentsAttachedToContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.listAttachedSegments({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listAttachedSegments( - request: Intercom.ListSegmentsAttachedToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions)); - } - - private async __listAttachedSegments( - request: Intercom.ListSegmentsAttachedToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/segments`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/segments", - ); - } - - /** - * 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.ListAttachedSubscriptionsRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.listAttachedSubscriptions({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listAttachedSubscriptions( - request: Intercom.ListAttachedSubscriptionsRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedSubscriptions(request, requestOptions)); - } - - private async __listAttachedSubscriptions( - request: Intercom.ListAttachedSubscriptionsRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/subscriptions", - ); - } - - /** - * 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.AttachSubscriptionToContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.attachSubscription({ - * contact_id: "63a07ddf05a32042dffac965", - * id: "37846", - * consent_type: "opt_in" - * }) - * - * @example - * await client.contacts.attachSubscription({ - * contact_id: "63a07ddf05a32042dffac965", - * id: "invalid_id", - * consent_type: "opt_in" - * }) - */ - public attachSubscription( - request: Intercom.AttachSubscriptionToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachSubscription(request, requestOptions)); - } - - private async __attachSubscription( - request: Intercom.AttachSubscriptionToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/contacts/{contact_id}/subscriptions", - ); - } - - /** - * 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.DetachSubscriptionFromContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.detachSubscription({ - * contact_id: "63a07ddf05a32042dffac965", - * subscription_id: "37846" - * }) - */ - public detachSubscription( - request: Intercom.DetachSubscriptionFromContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachSubscription(request, requestOptions)); - } - - private async __detachSubscription( - request: Intercom.DetachSubscriptionFromContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, subscription_id: subscriptionId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions/${core.url.encodePathParam(subscriptionId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/subscriptions/{subscription_id}", - ); - } - - /** - * You can fetch a list of all tags that are attached to a specific contact. - * - * @param {Intercom.ListTagsAttachedToContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.contacts.listAttachedTags({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public listAttachedTags( - request: Intercom.ListTagsAttachedToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedTags(request, requestOptions)); - } - - private async __listAttachedTags( - request: Intercom.ListTagsAttachedToContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}/tags"); - } - - /** - * You can fetch the details of a single contact. - * - * @param {Intercom.FindContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.find({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public find( - request: Intercom.FindContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContactsFindResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}"); - } - - /** - * 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.UpdateContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.update({ - * contact_id: "63a07ddf05a32042dffac965", - * email: "joebloggs@intercom.io", - * name: "joe bloggs" - * }) - * - * @example - * await client.contacts.update({ - * contact_id: "63a07ddf05a32042dffac965", - * custom_attributes: { - * "order": [ - * "21" - * ] - * } - * }) - */ - public update( - request: Intercom.UpdateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContactsUpdateResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/{contact_id}"); - } - - /** - * You can delete a single contact. - * - * @param {Intercom.DeleteContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.delete({ - * contact_id: "contact_id" - * }) - */ - public delete( - request: Intercom.DeleteContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.DeleteContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{contact_id}"); - } - - /** - * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. - * - * @param {Intercom.MergeContactsRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.mergeLeadInUser({ - * from: "6762f0d51bb69f9f2193bb7f", - * into: "6762f0d51bb69f9f2193bb80" - * }) - */ - public mergeLeadInUser( - request: Intercom.MergeContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__mergeLeadInUser(request, requestOptions)); - } - - private async __mergeLeadInUser( - request: Intercom.MergeContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/merge", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.ContactsMergeLeadInUserResponse, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge"); - } - - /** - * 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 | - * | 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.SearchRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.search({ - * query: { - * operator: "AND", - * value: [{ - * field: "created_at", - * operator: ">", - * value: "1306054154" - * }] - * }, - * pagination: { - * per_page: 5 - * } - * }) - */ - public async search( - request: Intercom.SearchRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const list = core.HttpResponsePromise.interceptFunction( - async (request: Intercom.SearchRequest): Promise> => { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/search"); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.pages?.next?.starting_after != null && - !( - typeof response?.pages?.next?.starting_after === "string" && - response?.pages?.next?.starting_after === "" - ), - getItems: (response) => response?.data ?? [], - loadPage: (response) => { - return list( - core.setObjectProperty(request, "pagination.starting_after", response?.pages?.next?.starting_after), - ); - }, - }); - } - - /** - * 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 {Intercom.ListContactsRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.list() - */ - public async list( - request: Intercom.ListContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts"); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.pages?.next?.starting_after != null && - !( - typeof response?.pages?.next?.starting_after === "string" && - response?.pages?.next?.starting_after === "" - ), - getItems: (response) => response?.data ?? [], - loadPage: (response) => { - return list(core.setObjectProperty(request, "starting_after", response?.pages?.next?.starting_after)); - }, - }); - } - - /** - * You can create a new contact (ie. user or lead). - * - * @param {Intercom.CreateContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.create({ - * email: "joebloggs@intercom.io" - * }) - */ - public create( - request: Intercom.CreateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ContactsCreateResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts"); - } - - /** - * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. - * - * @param {Intercom.ShowContactByExternalIdRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.contacts.showContactByExternalId({ - * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" - * }) - */ - public showContactByExternalId( - request: Intercom.ShowContactByExternalIdRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions)); - } - - private async __showContactByExternalId( - request: Intercom.ShowContactByExternalIdRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { external_id: externalId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/find_by_external_id/${core.url.encodePathParam(externalId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.ShowContactByExternalIdResponse, - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/find_by_external_id/{external_id}", - ); - } - - /** - * You can archive a single contact. - * - * @param {Intercom.ArchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.contacts.archive({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public archive( - request: Intercom.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__archive(request, requestOptions)); - } - - private async __archive( - request: Intercom.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/archive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/contacts/{contact_id}/archive", - ); - } - - /** - * You can unarchive a single contact. - * - * @param {Intercom.UnarchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.contacts.unarchive({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public unarchive( - request: Intercom.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__unarchive(request, requestOptions)); - } - - private async __unarchive( - request: Intercom.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/unarchive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/contacts/{contact_id}/unarchive", - ); - } - - /** - * 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.BlockContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.contacts.blockContact({ - * contact_id: "63a07ddf05a32042dffac965" - * }) - */ - public blockContact( - request: Intercom.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions)); - } - - private async __blockContact( - request: Intercom.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/block`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{contact_id}/block"); - } -} diff --git a/src/api/resources/contacts/client/index.ts b/src/api/resources/contacts/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/contacts/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts b/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts deleted file mode 100644 index 9a3380a0..00000000 --- a/src/api/resources/contacts/client/requests/ArchiveContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface ArchiveContactRequest { - /** contact_id */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts b/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts deleted file mode 100644 index 8bd134af..00000000 --- a/src/api/resources/contacts/client/requests/AttachSubscriptionToContactRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 AttachSubscriptionToContactRequest { - /** 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/contacts/client/requests/BlockContactRequest.ts b/src/api/resources/contacts/client/requests/BlockContactRequest.ts deleted file mode 100644 index 538c9a21..00000000 --- a/src/api/resources/contacts/client/requests/BlockContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface BlockContactRequest { - /** contact_id */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/DeleteContactRequest.ts b/src/api/resources/contacts/client/requests/DeleteContactRequest.ts deleted file mode 100644 index 42fb1445..00000000 --- a/src/api/resources/contacts/client/requests/DeleteContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "contact_id" - * } - */ -export interface DeleteContactRequest { - /** contact_id */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts b/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts deleted file mode 100644 index d5a9e4e3..00000000 --- a/src/api/resources/contacts/client/requests/DetachSubscriptionFromContactRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965", - * subscription_id: "37846" - * } - */ -export interface DetachSubscriptionFromContactRequest { - /** 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 */ - subscription_id: string; -} diff --git a/src/api/resources/contacts/client/requests/FindContactRequest.ts b/src/api/resources/contacts/client/requests/FindContactRequest.ts deleted file mode 100644 index a73c27ad..00000000 --- a/src/api/resources/contacts/client/requests/FindContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface FindContactRequest { - /** contact_id */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts b/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts deleted file mode 100644 index bf57a734..00000000 --- a/src/api/resources/contacts/client/requests/ListAttachedCompaniesRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965", - * page: 1, - * per_page: 1 - * } - */ -export interface ListAttachedCompaniesRequest { - /** The unique identifier for the contact which is given by Intercom */ - contact_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/contacts/client/requests/ListAttachedSubscriptionsRequest.ts b/src/api/resources/contacts/client/requests/ListAttachedSubscriptionsRequest.ts deleted file mode 100644 index 12dce4dd..00000000 --- a/src/api/resources/contacts/client/requests/ListAttachedSubscriptionsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface ListAttachedSubscriptionsRequest { - /** The unique identifier for the contact which is given by Intercom */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/ListContactsRequest.ts b/src/api/resources/contacts/client/requests/ListContactsRequest.ts deleted file mode 100644 index 779b4121..00000000 --- a/src/api/resources/contacts/client/requests/ListContactsRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * {} - */ -export interface ListContactsRequest { - /** 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; - /** String used to get the next page of conversations. */ - starting_after?: string; -} diff --git a/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts b/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts deleted file mode 100644 index f2fe1a11..00000000 --- a/src/api/resources/contacts/client/requests/ListSegmentsAttachedToContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface ListSegmentsAttachedToContactRequest { - /** The unique identifier for the contact which is given by Intercom */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts b/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts deleted file mode 100644 index 1d62aa60..00000000 --- a/src/api/resources/contacts/client/requests/ListTagsAttachedToContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface ListTagsAttachedToContactRequest { - /** The unique identifier for the contact which is given by Intercom */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/contacts/client/requests/MergeContactsRequest.ts deleted file mode 100644 index 520d7f83..00000000 --- a/src/api/resources/contacts/client/requests/MergeContactsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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/contacts/client/requests/ShowContactByExternalIdRequest.ts b/src/api/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts deleted file mode 100644 index d6f2b0d8..00000000 --- a/src/api/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/contacts/client/requests/UnarchiveContactRequest.ts b/src/api/resources/contacts/client/requests/UnarchiveContactRequest.ts deleted file mode 100644 index 76ecc8e1..00000000 --- a/src/api/resources/contacts/client/requests/UnarchiveContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965" - * } - */ -export interface UnarchiveContactRequest { - /** contact_id */ - contact_id: string; -} diff --git a/src/api/resources/contacts/client/requests/UpdateContactRequest.ts b/src/api/resources/contacts/client/requests/UpdateContactRequest.ts deleted file mode 100644 index 3f048efd..00000000 --- a/src/api/resources/contacts/client/requests/UpdateContactRequest.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965", - * email: "joebloggs@intercom.io", - * name: "joe bloggs" - * } - * - * @example - * { - * contact_id: "63a07ddf05a32042dffac965", - * custom_attributes: { - * "order": [ - * "21" - * ] - * } - * } - */ -export interface UpdateContactRequest { - /** id */ - contact_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/contacts/client/requests/index.ts b/src/api/resources/contacts/client/requests/index.ts deleted file mode 100644 index 60cacd37..00000000 --- a/src/api/resources/contacts/client/requests/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export type { ArchiveContactRequest } from "./ArchiveContactRequest.js"; -export type { AttachSubscriptionToContactRequest } from "./AttachSubscriptionToContactRequest.js"; -export type { BlockContactRequest } from "./BlockContactRequest.js"; -export type { DeleteContactRequest } from "./DeleteContactRequest.js"; -export type { DetachSubscriptionFromContactRequest } from "./DetachSubscriptionFromContactRequest.js"; -export type { FindContactRequest } from "./FindContactRequest.js"; -export type { ListAttachedCompaniesRequest } from "./ListAttachedCompaniesRequest.js"; -export type { ListAttachedSubscriptionsRequest } from "./ListAttachedSubscriptionsRequest.js"; -export type { ListContactsRequest } from "./ListContactsRequest.js"; -export type { ListSegmentsAttachedToContactRequest } from "./ListSegmentsAttachedToContactRequest.js"; -export type { ListTagsAttachedToContactRequest } from "./ListTagsAttachedToContactRequest.js"; -export type { MergeContactsRequest } from "./MergeContactsRequest.js"; -export type { ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest.js"; -export type { UnarchiveContactRequest } from "./UnarchiveContactRequest.js"; -export type { UpdateContactRequest } from "./UpdateContactRequest.js"; diff --git a/src/api/resources/contacts/index.ts b/src/api/resources/contacts/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/contacts/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/contacts/types/Contact.ts b/src/api/resources/contacts/types/Contact.ts deleted file mode 100644 index 1df7ed44..00000000 --- a/src/api/resources/contacts/types/Contact.ts +++ /dev/null @@ -1,94 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * Contacts represent your leads and users in Intercom. - */ -export interface Contact { - /** The type of object. */ - 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; - /** 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 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; - /** An image URL containing the avatar of a contact. */ - avatar?: string; - tags?: Intercom.ContactTags; - notes?: Intercom.ContactNotes; - companies?: Intercom.ContactCompanies; - location?: Intercom.ContactLocation; - social_profiles?: Intercom.ContactSocialProfiles; -} diff --git a/src/api/resources/contacts/types/ContactsCreateResponse.ts b/src/api/resources/contacts/types/ContactsCreateResponse.ts deleted file mode 100644 index c124d661..00000000 --- a/src/api/resources/contacts/types/ContactsCreateResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsCreateResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsFindResponse.ts b/src/api/resources/contacts/types/ContactsFindResponse.ts deleted file mode 100644 index 96ff7ff5..00000000 --- a/src/api/resources/contacts/types/ContactsFindResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsFindResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts b/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts deleted file mode 100644 index 95ca8cfb..00000000 --- a/src/api/resources/contacts/types/ContactsMergeLeadInUserResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsMergeLeadInUserResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ContactsUpdateResponse.ts b/src/api/resources/contacts/types/ContactsUpdateResponse.ts deleted file mode 100644 index 736895ee..00000000 --- a/src/api/resources/contacts/types/ContactsUpdateResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ContactsUpdateResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts b/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts deleted file mode 100644 index c6dbf5c1..00000000 --- a/src/api/resources/contacts/types/ShowContactByExternalIdResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export interface ShowContactByExternalIdResponse extends Intercom.Contact { - /** If the user has enabled push messaging. */ - enabled_push_messaging?: boolean; -} diff --git a/src/api/resources/contacts/types/index.ts b/src/api/resources/contacts/types/index.ts deleted file mode 100644 index adc73bae..00000000 --- a/src/api/resources/contacts/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./Contact.js"; -export * from "./ContactsCreateResponse.js"; -export * from "./ContactsFindResponse.js"; -export * from "./ContactsMergeLeadInUserResponse.js"; -export * from "./ContactsUpdateResponse.js"; -export * from "./ShowContactByExternalIdResponse.js"; diff --git a/src/api/resources/conversations/client/Client.ts b/src/api/resources/conversations/client/Client.ts deleted file mode 100644 index af9f6fc0..00000000 --- a/src/api/resources/conversations/client/Client.ts +++ /dev/null @@ -1,1450 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace ConversationsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Conversations - */ -export class ConversationsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ConversationsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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.ListConversationsRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * - * @example - * await client.conversations.list({ - * per_page: 1, - * starting_after: "starting_after" - * }) - */ - public async list( - request: Intercom.ListConversationsRequest = {}, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ConversationList, 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, - }); - } - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations"); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.pages?.next?.starting_after != null && - !( - typeof response?.pages?.next?.starting_after === "string" && - response?.pages?.next?.starting_after === "" - ), - getItems: (response) => response?.conversations ?? [], - loadPage: (response) => { - return list(core.setObjectProperty(request, "starting_after", response?.pages?.next?.starting_after)); - }, - }); - } - - /** - * 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.CreateConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.create({ - * from: { - * type: "user", - * id: "6762f11b1bb69f9f2193bba3" - * }, - * body: "Hello there" - * }) - * - * @example - * await client.conversations.create({ - * from: { - * type: "user", - * id: "123_doesnt_exist" - * }, - * body: "Hello there" - * }) - */ - public create( - request: Intercom.CreateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations"); - } - - /** - * - * 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.FindConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.find({ - * conversation_id: "123", - * display_as: "plaintext", - * include_translations: true - * }) - */ - public find( - request: Intercom.FindConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { - conversation_id: conversationId, - display_as: displayAs, - include_translations: includeTranslations, - } = request; - const _queryParams: Record = {}; - if (displayAs != null) { - _queryParams.display_as = displayAs; - } - - if (includeTranslations != null) { - _queryParams.include_translations = includeTranslations.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/conversations/{conversation_id}", - ); - } - - /** - * - * 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.UpdateConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.update({ - * conversation_id: "conversation_id", - * display_as: "plaintext", - * read: true, - * title: "new conversation title", - * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" - * } - * }) - * - * @example - * await client.conversations.update({ - * conversation_id: "conversation_id", - * display_as: "plaintext", - * custom_attributes: { - * "order": {} - * } - * }) - */ - public update( - request: Intercom.UpdateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, display_as: displayAs, ..._body } = request; - const _queryParams: Record = {}; - if (displayAs != null) { - _queryParams.display_as = displayAs; - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/conversations/{conversation_id}", - ); - } - - /** - * You can delete a single conversation. - * - * @param {Intercom.DeleteConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * - * @example - * await client.conversations.deleteConversation({ - * conversation_id: 1 - * }) - */ - public deleteConversation( - request: Intercom.DeleteConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteConversation(request, requestOptions)); - } - - private async __deleteConversation( - request: Intercom.DeleteConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.ConversationDeleted, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}", - ); - } - - /** - * 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.SearchRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.conversations.search({ - * query: { - * operator: "AND", - * value: [{ - * field: "created_at", - * operator: ">", - * value: "1306054154" - * }] - * }, - * pagination: { - * per_page: 5 - * } - * }) - */ - public async search( - request: Intercom.SearchRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const list = core.HttpResponsePromise.interceptFunction( - async (request: Intercom.SearchRequest): Promise> => { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.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, - }); - } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/search", - ); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.pages?.next?.starting_after != null && - !( - typeof response?.pages?.next?.starting_after === "string" && - response?.pages?.next?.starting_after === "" - ), - getItems: (response) => response?.conversations ?? [], - loadPage: (response) => { - return list( - core.setObjectProperty(request, "pagination.starting_after", response?.pages?.next?.starting_after), - ); - }, - }); - } - - /** - * 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.ReplyToConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.reply({ - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1571bb69f9f2193bbbb" - * } - * }) - * - * @example - * await client.conversations.reply({ - * conversation_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.conversations.reply({ - * conversation_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.conversations.reply({ - * conversation_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.conversations.reply({ - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1661bb69f9f2193bbbf" - * } - * }) - */ - public reply( - request: Intercom.ReplyToConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__reply(request, requestOptions)); - } - - private async __reply( - request: Intercom.ReplyToConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/reply`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/reply", - ); - } - - /** - * 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.ManageConversationPartsRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.manage({ - * conversation_id: "123", - * body: { - * message_type: "close", - * type: "admin", - * admin_id: "12345" - * } - * }) - * - * @example - * await client.conversations.manage({ - * conversation_id: "123", - * body: { - * message_type: "snoozed", - * admin_id: "5017691", - * snoozed_until: 1673609604 - * } - * }) - * - * @example - * await client.conversations.manage({ - * conversation_id: "123", - * body: { - * message_type: "open", - * admin_id: "5017690" - * } - * }) - * - * @example - * await client.conversations.manage({ - * conversation_id: "123", - * body: { - * message_type: "assignment", - * type: "admin", - * admin_id: "12345", - * assignee_id: "4324241" - * } - * }) - */ - public manage( - request: Intercom.ManageConversationPartsRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__manage(request, requestOptions)); - } - - private async __manage( - request: Intercom.ManageConversationPartsRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/parts`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/parts", - ); - } - - /** - * 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.AttachContactToConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.attachContactAsAdmin({ - * conversation_id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19b1bb69f9f2193bbd4" - * } - * }) - * - * @example - * await client.conversations.attachContactAsAdmin({ - * conversation_id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19e1bb69f9f2193bbd5" - * } - * }) - */ - public attachContactAsAdmin( - request: Intercom.AttachContactToConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContactAsAdmin(request, requestOptions)); - } - - private async __attachContactAsAdmin( - request: Intercom.AttachContactToConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/customers`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/customers", - ); - } - - /** - * 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.DetachContactFromConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.conversations.detachContactAsAdmin({ - * conversation_id: "123", - * contact_id: "123", - * admin_id: "5017690" - * }) - */ - public detachContactAsAdmin( - request: Intercom.DetachContactFromConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContactAsAdmin(request, requestOptions)); - } - - private async __detachContactAsAdmin( - request: Intercom.DetachContactFromConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/customers/${core.url.encodePathParam(contactId)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}/customers/{contact_id}", - ); - } - - /** - * 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.RedactConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.redactConversationPart({ - * type: "conversation_part", - * conversation_id: "19894788788", - * conversation_part_id: "19381789428" - * }) - * - * @example - * await client.conversations.redactConversationPart({ - * type: "conversation_part", - * conversation_id: "really_123_doesnt_exist", - * conversation_part_id: "really_123_doesnt_exist" - * }) - */ - public redactConversationPart( - request: Intercom.RedactConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__redactConversationPart(request, requestOptions)); - } - - private async __redactConversationPart( - request: Intercom.RedactConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations/redact", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/redact"); - } - - /** - * You can convert a conversation to a ticket. - * - * @param {Intercom.ConvertConversationToTicketRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * - * @example - * await client.conversations.convertToTicket({ - * conversation_id: 1, - * ticket_type_id: "53" - * }) - * - * @example - * await client.conversations.convertToTicket({ - * conversation_id: 1, - * ticket_type_id: "54" - * }) - */ - public convertToTicket( - request: Intercom.ConvertConversationToTicketRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__convertToTicket(request, requestOptions)); - } - - private async __convertToTicket( - request: Intercom.ConvertConversationToTicketRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/convert`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Ticket | 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, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/convert", - ); - } - - /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. - * {% /admonition %} - * - * @param {Intercom.AutoAssignConversationRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.conversations.runAssignmentRules({ - * conversation_id: "123" - * }) - */ - public runAssignmentRules( - request: Intercom.AutoAssignConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__runAssignmentRules(request, requestOptions)); - } - - private async __runAssignmentRules( - request: Intercom.AutoAssignConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/run_assignment_rules`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - case 403: - throw new Intercom.ForbiddenError(_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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/run_assignment_rules", - ); - } -} diff --git a/src/api/resources/conversations/client/index.ts b/src/api/resources/conversations/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/conversations/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts b/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts deleted file mode 100644 index 26b7dd3a..00000000 --- a/src/api/resources/conversations/client/requests/AttachContactToConversationRequest.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * conversation_id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19b1bb69f9f2193bbd4" - * } - * } - * - * @example - * { - * conversation_id: "123", - * admin_id: "12345", - * customer: { - * intercom_user_id: "6762f19e1bb69f9f2193bbd5" - * } - * } - */ -export interface AttachContactToConversationRequest { - /** The identifier for the conversation as given by Intercom. */ - conversation_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.CustomerRequest | undefined; - } - | { - user_id: string; - customer?: Intercom.CustomerRequest | undefined; - } - | { - email: string; - customer?: Intercom.CustomerRequest | undefined; - }; -} diff --git a/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts b/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts deleted file mode 100644 index a5a03bdc..00000000 --- a/src/api/resources/conversations/client/requests/AutoAssignConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_id: "123" - * } - */ -export interface AutoAssignConversationRequest { - /** The identifier for the conversation as given by Intercom. */ - conversation_id: string; -} diff --git a/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts b/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts deleted file mode 100644 index c5593cee..00000000 --- a/src/api/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * conversation_id: 1, - * ticket_type_id: "53" - * } - * - * @example - * { - * conversation_id: 1, - * ticket_type_id: "54" - * } - */ -export interface ConvertConversationToTicketRequest { - /** The id of the conversation to target */ - conversation_id: number; - /** The ID of the type of ticket you want to convert the conversation to */ - ticket_type_id: string; - attributes?: Intercom.TicketRequestCustomAttributes; -} diff --git a/src/api/resources/conversations/client/requests/CreateConversationRequest.ts b/src/api/resources/conversations/client/requests/CreateConversationRequest.ts deleted file mode 100644 index 0f8bcd9a..00000000 --- a/src/api/resources/conversations/client/requests/CreateConversationRequest.ts +++ /dev/null @@ -1,47 +0,0 @@ -// 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 const Type = { - Lead: "lead", - User: "user", - Contact: "contact", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } -} diff --git a/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts deleted file mode 100644 index a5bf5e64..00000000 --- a/src/api/resources/conversations/client/requests/DeleteConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_id: 1 - * } - */ -export interface DeleteConversationRequest { - /** id */ - conversation_id: number; -} diff --git a/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts b/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts deleted file mode 100644 index 415bfae9..00000000 --- a/src/api/resources/conversations/client/requests/DetachContactFromConversationRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// 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/conversations/client/requests/FindConversationRequest.ts b/src/api/resources/conversations/client/requests/FindConversationRequest.ts deleted file mode 100644 index c80a7032..00000000 --- a/src/api/resources/conversations/client/requests/FindConversationRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_id: "123", - * display_as: "plaintext", - * include_translations: true - * } - */ -export interface FindConversationRequest { - /** The id of the conversation to target */ - conversation_id: string; - /** Set to plaintext to retrieve conversation messages in plain text. */ - display_as?: string; - /** If set to true, conversation parts will be translated to the detected language of the conversation. */ - include_translations?: boolean; -} diff --git a/src/api/resources/conversations/client/requests/ListConversationsRequest.ts b/src/api/resources/conversations/client/requests/ListConversationsRequest.ts deleted file mode 100644 index 4908f563..00000000 --- a/src/api/resources/conversations/client/requests/ListConversationsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * per_page: 1, - * starting_after: "starting_after" - * } - */ -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/conversations/client/requests/ManageConversationPartsRequest.ts b/src/api/resources/conversations/client/requests/ManageConversationPartsRequest.ts deleted file mode 100644 index a16fe3ec..00000000 --- a/src/api/resources/conversations/client/requests/ManageConversationPartsRequest.ts +++ /dev/null @@ -1,60 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * conversation_id: "123", - * body: { - * message_type: "close", - * type: "admin", - * admin_id: "12345" - * } - * } - * - * @example - * { - * conversation_id: "123", - * body: { - * message_type: "snoozed", - * admin_id: "5017691", - * snoozed_until: 1673609604 - * } - * } - * - * @example - * { - * conversation_id: "123", - * body: { - * message_type: "open", - * admin_id: "5017690" - * } - * } - * - * @example - * { - * conversation_id: "123", - * body: { - * message_type: "assignment", - * type: "admin", - * admin_id: "12345", - * assignee_id: "4324241" - * } - * } - * - * @example - * { - * conversation_id: "123", - * body: { - * message_type: "close", - * type: "admin", - * admin_id: "12345" - * } - * } - */ -export interface ManageConversationPartsRequest { - /** The identifier for the conversation as given by Intercom. */ - conversation_id: string; - body: Intercom.ConversationsManageRequestBody; -} diff --git a/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts b/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts deleted file mode 100644 index 9ef917d8..00000000 --- a/src/api/resources/conversations/client/requests/ReplyToConversationRequest.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1571bb69f9f2193bbbb" - * } - * } - * - * @example - * { - * conversation_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 - * { - * conversation_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 - * { - * conversation_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 - * { - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1661bb69f9f2193bbbf" - * } - * } - * - * @example - * { - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1571bb69f9f2193bbbb" - * } - * } - * - * @example - * { - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1571bb69f9f2193bbbb" - * } - * } - * - * @example - * { - * conversation_id: "123 or \"last\"", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f1571bb69f9f2193bbbb" - * } - * } - */ -export interface ReplyToConversationRequest { - /** The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation */ - conversation_id: string; - body: Intercom.ReplyConversationRequest; -} diff --git a/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts b/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts deleted file mode 100644 index 164ecefe..00000000 --- a/src/api/resources/conversations/client/requests/UpdateConversationRequest.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * conversation_id: "conversation_id", - * display_as: "plaintext", - * read: true, - * title: "new conversation title", - * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" - * } - * } - * - * @example - * { - * conversation_id: "conversation_id", - * display_as: "plaintext", - * custom_attributes: { - * "order": {} - * } - * } - * - * @example - * { - * conversation_id: "conversation_id", - * 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 */ - conversation_id: string; - /** 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.CustomAttributes; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ - company_id?: string; -} diff --git a/src/api/resources/conversations/client/requests/index.ts b/src/api/resources/conversations/client/requests/index.ts deleted file mode 100644 index dbe79ca7..00000000 --- a/src/api/resources/conversations/client/requests/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type { AttachContactToConversationRequest } from "./AttachContactToConversationRequest.js"; -export type { AutoAssignConversationRequest } from "./AutoAssignConversationRequest.js"; -export type { ConvertConversationToTicketRequest } from "./ConvertConversationToTicketRequest.js"; -export type { CreateConversationRequest } from "./CreateConversationRequest.js"; -export type { DeleteConversationRequest } from "./DeleteConversationRequest.js"; -export type { DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest.js"; -export type { FindConversationRequest } from "./FindConversationRequest.js"; -export type { ListConversationsRequest } from "./ListConversationsRequest.js"; -export type { ManageConversationPartsRequest } from "./ManageConversationPartsRequest.js"; -export type { ReplyToConversationRequest } from "./ReplyToConversationRequest.js"; -export type { UpdateConversationRequest } from "./UpdateConversationRequest.js"; diff --git a/src/api/resources/conversations/index.ts b/src/api/resources/conversations/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/conversations/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/conversations/types/Conversation.ts b/src/api/resources/conversations/types/Conversation.ts deleted file mode 100644 index bf5334b2..00000000 --- a/src/api/resources/conversations/types/Conversation.ts +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. */ - company_id?: string; - tags?: Intercom.Tags; - conversation_rating?: Intercom.ConversationRating; - source: Intercom.ConversationSource; - contacts: Intercom.ConversationContacts; - teammates?: Intercom.ConversationTeammates; - custom_attributes: Intercom.CustomAttributes; - first_contact_reply?: Intercom.ConversationFirstContactReply; - sla_applied?: Intercom.SlaApplied; - statistics?: Intercom.ConversationStatistics; - conversation_parts?: Intercom.ConversationParts; - linked_objects?: Intercom.LinkedObjectList; - /** Indicates whether the AI Agent participated in the conversation. */ - ai_agent_participated?: boolean; - ai_agent?: Intercom.AiAgent; -} - -export namespace Conversation { - /** Can be set to "open", "closed" or "snoozed". */ - export const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** If marked as priority, it will return priority or else not_priority. */ - export const Priority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type Priority = (typeof Priority)[keyof typeof Priority]; -} diff --git a/src/api/resources/conversations/types/ConversationsManageRequestBody.ts b/src/api/resources/conversations/types/ConversationsManageRequestBody.ts deleted file mode 100644 index 7a8ef883..00000000 --- a/src/api/resources/conversations/types/ConversationsManageRequestBody.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type ConversationsManageRequestBody = - | Intercom.ConversationsManageRequestBody.Close - | Intercom.ConversationsManageRequestBody.Snoozed - | Intercom.ConversationsManageRequestBody.Open - | Intercom.ConversationsManageRequestBody.Assignment; - -export namespace ConversationsManageRequestBody { - export interface Close extends Intercom.CloseConversationRequest { - message_type: "close"; - } - - export interface Snoozed extends Intercom.SnoozeConversationRequest { - message_type: "snoozed"; - } - - export interface Open extends Intercom.OpenConversationRequest { - message_type: "open"; - } - - export interface Assignment extends Intercom.AssignConversationRequest { - message_type: "assignment"; - } -} diff --git a/src/api/resources/conversations/types/index.ts b/src/api/resources/conversations/types/index.ts deleted file mode 100644 index 062aeafd..00000000 --- a/src/api/resources/conversations/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Conversation.js"; -export * from "./ConversationsManageRequestBody.js"; diff --git a/src/api/resources/customChannelEvents/client/Client.ts b/src/api/resources/customChannelEvents/client/Client.ts deleted file mode 100644 index 4ba0127c..00000000 --- a/src/api/resources/customChannelEvents/client/Client.ts +++ /dev/null @@ -1,423 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace CustomChannelEventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * With the "Custom Channel" integration, you can bring Fin and Intercom capabilities to your own platform via API, enabling powerful custom integrations. - * - * Intercom treats your integration like any other Intercom channel, allowing your application and Intercom to exchange events seamlessly. This makes it possible, for example, for your users to interact with Fin directly within your own application’s UI. - * - * > **Note:** "Fin over API" is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - */ -export class CustomChannelEventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomChannelEventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.CustomChannelBaseEvent} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyNewConversation({ - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyNewConversation( - request: Intercom.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions)); - } - - private async __notifyNewConversation( - request: Intercom.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_conversation", - ); - } - - /** - * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyNewMessageRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyNewMessage({ - * body: "body", - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyNewMessage( - request: Intercom.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions)); - } - - private async __notifyNewMessage( - request: Intercom.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_message", - ); - } - - /** - * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyQuickReplySelectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.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.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions)); - } - - private async __notifyQuickReplySelected( - request: Intercom.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_quick_reply_selected", - ); - } - - /** - * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.NotifyAttributeCollectedRequest} request - * @param {CustomChannelEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.customChannelEvents.notifyAttributeCollected({ - * attribute: { - * id: "id", - * value: "value" - * }, - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * }) - */ - public notifyAttributeCollected( - request: Intercom.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions)); - } - - private async __notifyAttributeCollected( - request: Intercom.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomChannelNotificationResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_attribute_collected", - ); - } -} diff --git a/src/api/resources/customChannelEvents/client/index.ts b/src/api/resources/customChannelEvents/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/customChannelEvents/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts deleted file mode 100644 index a4a040d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * attribute: { - * id: "id", - * value: "value" - * }, - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * } - */ -export interface NotifyAttributeCollectedRequest extends Intercom.CustomChannelBaseEvent { - attribute: Intercom.CustomChannelAttribute; -} diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts deleted file mode 100644 index 7f6483df..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * body: "body", - * event_id: "event_id", - * external_conversation_id: "external_conversation_id", - * contact: { - * type: "user", - * external_id: "external_id" - * } - * } - */ -export interface NotifyNewMessageRequest extends Intercom.CustomChannelBaseEvent { - /** The message content sent by the user. */ - body: string; -} diff --git a/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts b/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts deleted file mode 100644 index e6cec3d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @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.CustomChannelBaseEvent { - /** Id of the selected quick reply option. */ - quick_reply_option_id: string; -} diff --git a/src/api/resources/customChannelEvents/client/requests/index.ts b/src/api/resources/customChannelEvents/client/requests/index.ts deleted file mode 100644 index 702922d9..00000000 --- a/src/api/resources/customChannelEvents/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest.js"; -export type { NotifyNewMessageRequest } from "./NotifyNewMessageRequest.js"; -export type { NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest.js"; diff --git a/src/api/resources/customChannelEvents/index.ts b/src/api/resources/customChannelEvents/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/customChannelEvents/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/customObjectInstances/client/Client.ts b/src/api/resources/customObjectInstances/client/Client.ts deleted file mode 100644 index 0ae03367..00000000 --- a/src/api/resources/customObjectInstances/client/Client.ts +++ /dev/null @@ -1,462 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace CustomObjectInstancesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * 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 CustomObjectInstancesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomObjectInstancesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Fetch a Custom Object Instance by external_id. - * - * @param {Intercom.GetCustomObjectInstancesByExternalIdRequest} request - * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - * custom_object_type_identifier: "Order", - * external_id: "external_id" - * }) - */ - public getCustomObjectInstancesByExternalId( - request: Intercom.GetCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__getCustomObjectInstancesByExternalId(request, requestOptions), - ); - } - - private async __getCustomObjectInstancesByExternalId( - request: Intercom.GetCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; - const _queryParams: Record = {}; - _queryParams.external_id = externalId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomObjectInstance | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Create or update a custom object instance - * - * @param {Intercom.CreateOrUpdateCustomObjectInstanceRequest} request - * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.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.CreateOrUpdateCustomObjectInstanceRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createCustomObjectInstances(request, requestOptions)); - } - - private async __createCustomObjectInstances( - request: Intercom.CreateOrUpdateCustomObjectInstanceRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomObjectInstance | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Delete a single Custom Object instance by external_id. - * - * @param {Intercom.DeleteCustomObjectInstancesByIdRequest} request - * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.customObjectInstances.deleteCustomObjectInstancesById({ - * custom_object_type_identifier: "Order", - * external_id: "external_id" - * }) - */ - public deleteCustomObjectInstancesById( - request: Intercom.DeleteCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCustomObjectInstancesById(request, requestOptions)); - } - - private async __deleteCustomObjectInstancesById( - request: Intercom.DeleteCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; - const _queryParams: Record = {}; - _queryParams.external_id = externalId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.CustomObjectInstanceDeleted, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Fetch a Custom Object Instance by id. - * - * @param {Intercom.GetCustomObjectInstancesByIdRequest} request - * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.customObjectInstances.getCustomObjectInstancesById({ - * custom_object_type_identifier: "Order", - * custom_object_instance_id: "custom_object_instance_id" - * }) - */ - public getCustomObjectInstancesById( - request: Intercom.GetCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getCustomObjectInstancesById(request, requestOptions)); - } - - private async __getCustomObjectInstancesById( - request: Intercom.GetCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { - custom_object_type_identifier: customObjectTypeIdentifier, - custom_object_instance_id: customObjectInstanceId, - } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(customObjectInstanceId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.CustomObjectInstance | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/custom_object_instances/{custom_object_type_identifier}/{custom_object_instance_id}", - ); - } - - /** - * Delete a single Custom Object instance using the Intercom defined id. - * - * @param {Intercom.DeleteCustomObjectInstancesByExternalIdRequest} request - * @param {CustomObjectInstancesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - * custom_object_type_identifier: "Order", - * custom_object_instance_id: "custom_object_instance_id" - * }) - */ - public deleteCustomObjectInstancesByExternalId( - request: Intercom.DeleteCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__deleteCustomObjectInstancesByExternalId(request, requestOptions), - ); - } - - private async __deleteCustomObjectInstancesByExternalId( - request: Intercom.DeleteCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { - custom_object_type_identifier: customObjectTypeIdentifier, - custom_object_instance_id: customObjectInstanceId, - } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(customObjectInstanceId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.CustomObjectInstanceDeleted, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/custom_object_instances/{custom_object_type_identifier}/{custom_object_instance_id}", - ); - } -} diff --git a/src/api/resources/customObjectInstances/client/index.ts b/src/api/resources/customObjectInstances/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/customObjectInstances/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts b/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts deleted file mode 100644 index 97fa7ad7..00000000 --- a/src/api/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts deleted file mode 100644 index 16385f5b..00000000 --- a/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * custom_object_type_identifier: "Order", - * custom_object_instance_id: "custom_object_instance_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 */ - custom_object_instance_id: string; -} diff --git a/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts deleted file mode 100644 index d97bc1ce..00000000 --- a/src/api/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts deleted file mode 100644 index 2d9d0fe3..00000000 --- a/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts b/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts deleted file mode 100644 index 962a1337..00000000 --- a/src/api/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * custom_object_type_identifier: "Order", - * custom_object_instance_id: "custom_object_instance_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 */ - custom_object_instance_id: string; -} diff --git a/src/api/resources/customObjectInstances/client/requests/index.ts b/src/api/resources/customObjectInstances/client/requests/index.ts deleted file mode 100644 index 07816781..00000000 --- a/src/api/resources/customObjectInstances/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { CreateOrUpdateCustomObjectInstanceRequest } from "./CreateOrUpdateCustomObjectInstanceRequest.js"; -export type { DeleteCustomObjectInstancesByExternalIdRequest } from "./DeleteCustomObjectInstancesByExternalIdRequest.js"; -export type { DeleteCustomObjectInstancesByIdRequest } from "./DeleteCustomObjectInstancesByIdRequest.js"; -export type { GetCustomObjectInstancesByExternalIdRequest } from "./GetCustomObjectInstancesByExternalIdRequest.js"; -export type { GetCustomObjectInstancesByIdRequest } from "./GetCustomObjectInstancesByIdRequest.js"; diff --git a/src/api/resources/customObjectInstances/index.ts b/src/api/resources/customObjectInstances/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/customObjectInstances/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts deleted file mode 100644 index a4363acf..00000000 --- a/src/api/resources/customObjectInstances/types/CustomObjectInstance.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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/customObjectInstances/types/index.ts b/src/api/resources/customObjectInstances/types/index.ts deleted file mode 100644 index 861f9ce5..00000000 --- a/src/api/resources/customObjectInstances/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./CustomObjectInstance.js"; diff --git a/src/api/resources/dataAttributes/client/Client.ts b/src/api/resources/dataAttributes/client/Client.ts deleted file mode 100644 index acff8f55..00000000 --- a/src/api/resources/dataAttributes/client/Client.ts +++ /dev/null @@ -1,317 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace DataAttributesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Data Attributes - */ -export class DataAttributesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: DataAttributesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. - * - * @param {Intercom.ListDataAttributesRequest} request - * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.dataAttributes.list({ - * model: "contact", - * include_archived: true - * }) - */ - public list( - request: Intercom.ListDataAttributesRequest = {}, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); - } - - private async __list( - request: Intercom.ListDataAttributesRequest = {}, - requestOptions?: DataAttributesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "data_attributes", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/data_attributes"); - } - - /** - * You can create a data attributes for a `contact` or a `company`. - * - * @param {Intercom.CreateDataAttributeRequest} request - * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.dataAttributes.create({ - * data_type: "string" - * }) - * - * @example - * await client.dataAttributes.create({ - * data_type: "integer" - * }) - * - * @example - * await client.dataAttributes.create({ - * options: [{ - * value: "1-10" - * }] - * }) - */ - public create( - request: Intercom.CreateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "data_attributes", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/data_attributes"); - } - - /** - * - * 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.UpdateDataAttributeRequest} request - * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.dataAttributes.update({ - * data_attribute_id: 1, - * body: { - * options: [{ - * value: "1-10" - * }, { - * value: "11-20" - * }] - * } - * }) - * - * @example - * await client.dataAttributes.update({ - * data_attribute_id: 1, - * body: { - * options: [{ - * value: "1-10" - * }, { - * value: "11-50" - * }] - * } - * }) - * - * @example - * await client.dataAttributes.update({ - * data_attribute_id: 1, - * body: { - * "description": "Trying to archieve", - * "archived": true - * } - * }) - */ - public update( - request: Intercom.UpdateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { - const { data_attribute_id: dataAttributeId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `data_attributes/${core.url.encodePathParam(dataAttributeId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/data_attributes/{data_attribute_id}", - ); - } -} diff --git a/src/api/resources/dataAttributes/client/index.ts b/src/api/resources/dataAttributes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/dataAttributes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts b/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts deleted file mode 100644 index f90a07a7..00000000 --- a/src/api/resources/dataAttributes/client/requests/ListDataAttributesRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * model: "contact", - * include_archived: true - * } - */ -export interface ListDataAttributesRequest { - /** Specify the data attribute model to return. */ - model?: Intercom.DataAttributesListRequestModel; - /** Include archived attributes in the list. By default we return only non archived data attributes. */ - include_archived?: boolean; -} diff --git a/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts b/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts deleted file mode 100644 index 4b29b995..00000000 --- a/src/api/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * data_attribute_id: 1, - * body: { - * options: [{ - * value: "1-10" - * }, { - * value: "11-20" - * }] - * } - * } - * - * @example - * { - * data_attribute_id: 1, - * body: { - * options: [{ - * value: "1-10" - * }, { - * value: "11-50" - * }] - * } - * } - * - * @example - * { - * data_attribute_id: 1, - * body: { - * options: [{ - * value: "1-10" - * }, { - * value: "11-20" - * }] - * } - * } - * - * @example - * { - * data_attribute_id: 1, - * body: { - * "description": "Trying to archieve", - * "archived": true - * } - * } - */ -export interface UpdateDataAttributeRequest { - /** The data attribute id */ - data_attribute_id: number; - body: Intercom.UpdateDataAttributeRequestBody; -} diff --git a/src/api/resources/dataAttributes/client/requests/index.ts b/src/api/resources/dataAttributes/client/requests/index.ts deleted file mode 100644 index a1a5824f..00000000 --- a/src/api/resources/dataAttributes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { ListDataAttributesRequest } from "./ListDataAttributesRequest.js"; -export type { UpdateDataAttributeRequest } from "./UpdateDataAttributeRequest.js"; diff --git a/src/api/resources/dataAttributes/index.ts b/src/api/resources/dataAttributes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/dataAttributes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/dataAttributes/types/DataAttribute.ts deleted file mode 100644 index a2dbee88..00000000 --- a/src/api/resources/dataAttributes/types/DataAttribute.ts +++ /dev/null @@ -1,59 +0,0 @@ -// 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 const Model = { - Contact: "contact", - Company: "company", - } as const; - export type Model = (typeof Model)[keyof typeof Model]; - /** The data type of the attribute. */ - export const DataType = { - String: "string", - Integer: "integer", - Float: "float", - Boolean: "boolean", - Date: "date", - } as const; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts b/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts deleted file mode 100644 index 8c42df63..00000000 --- a/src/api/resources/dataAttributes/types/DataAttributesListRequestModel.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export const DataAttributesListRequestModel = { - Contact: "contact", - Company: "company", - Conversation: "conversation", -} as const; -export type DataAttributesListRequestModel = - (typeof DataAttributesListRequestModel)[keyof typeof DataAttributesListRequestModel]; diff --git a/src/api/resources/dataAttributes/types/index.ts b/src/api/resources/dataAttributes/types/index.ts deleted file mode 100644 index cf0add2c..00000000 --- a/src/api/resources/dataAttributes/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataAttribute.js"; -export * from "./DataAttributesListRequestModel.js"; diff --git a/src/api/resources/dataEvents/index.ts b/src/api/resources/dataEvents/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/dataEvents/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/dataEvents/types/DataEvent.ts b/src/api/resources/dataEvents/types/DataEvent.ts deleted file mode 100644 index 6efc5389..00000000 --- a/src/api/resources/dataEvents/types/DataEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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/dataEvents/types/index.ts b/src/api/resources/dataEvents/types/index.ts deleted file mode 100644 index 0272b738..00000000 --- a/src/api/resources/dataEvents/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./DataEvent.js"; diff --git a/src/api/resources/dataExport/client/Client.ts b/src/api/resources/dataExport/client/Client.ts deleted file mode 100644 index f9ea23e2..00000000 --- a/src/api/resources/dataExport/client/Client.ts +++ /dev/null @@ -1,475 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace DataExportClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Data Exports - */ -export class DataExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: DataExportClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * @param {Intercom.ExportReportingDataRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.dataExport.exportReportingData({ - * job_identifier: "job_identifier", - * app_id: "app_id", - * client_id: "client_id" - * }) - */ - public exportReportingData( - request: Intercom.ExportReportingDataRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__exportReportingData(request, requestOptions)); - } - - private async __exportReportingData( - request: Intercom.ExportReportingDataRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier, app_id: appId, client_id: clientId } = request; - const _queryParams: Record = {}; - _queryParams.app_id = appId; - _queryParams.client_id = clientId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/reporting_data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.DataExportExportReportingDataResponse, - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/export/reporting_data/{job_identifier}", - ); - } - - /** - * Download the data from a completed reporting data export job. - * - * > Octet header required - * > - * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. - * - * @param {Intercom.DownloadReportingDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.dataExport.downloadReportingDataExport({ - * job_identifier: "job_identifier", - * app_id: "app_id" - * }) - */ - public downloadReportingDataExport( - request: Intercom.DownloadReportingDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__downloadReportingDataExport(request, requestOptions)); - } - - private async __downloadReportingDataExport( - request: Intercom.DownloadReportingDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier, app_id: appId } = request; - const _queryParams: Record = {}; - _queryParams.app_id = appId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ - Accept: "application/octet-stream", - "Intercom-Version": requestOptions?.version, - }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `download/reporting_data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: undefined, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/download/reporting_data/{job_identifier}", - ); - } - - /** - * 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.CreateDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.dataExport.create({ - * created_at_after: 1734519776, - * created_at_before: 1734537776 - * }) - */ - public create( - request: Intercom.CreateDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "export/content/data", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/export/content/data"); - } - - /** - * 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.FindDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.dataExport.find({ - * job_identifier: "job_identifier" - * }) - */ - public find( - request: Intercom.FindDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/content/data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/export/content/data/{job_identifier}", - ); - } - - /** - * You can cancel your job - * - * @param {Intercom.CancelDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.dataExport.cancel({ - * job_identifier: "job_identifier" - * }) - */ - public cancel( - request: Intercom.CancelDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__cancel(request, requestOptions)); - } - - private async __cancel( - request: Intercom.CancelDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/cancel/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/export/cancel/{job_identifier}", - ); - } - - /** - * 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.DownloadDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.dataExport.download({ - * job_identifier: "job_identifier" - * }) - */ - public download( - request: Intercom.DownloadDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__download(request, requestOptions)); - } - - private async __download( - request: Intercom.DownloadDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `download/content/data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/download/content/data/{job_identifier}", - ); - } -} diff --git a/src/api/resources/dataExport/client/index.ts b/src/api/resources/dataExport/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/dataExport/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts b/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts deleted file mode 100644 index 4e387ec1..00000000 --- a/src/api/resources/dataExport/client/requests/CancelDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/dataExport/client/requests/CreateDataExportRequest.ts b/src/api/resources/dataExport/client/requests/CreateDataExportRequest.ts deleted file mode 100644 index b0bc000c..00000000 --- a/src/api/resources/dataExport/client/requests/CreateDataExportRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * created_at_after: 1734519776, - * created_at_before: 1734537776 - * } - */ -export interface CreateDataExportRequest { - /** 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/dataExport/client/requests/DownloadDataExportRequest.ts b/src/api/resources/dataExport/client/requests/DownloadDataExportRequest.ts deleted file mode 100644 index 98aab0f3..00000000 --- a/src/api/resources/dataExport/client/requests/DownloadDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/dataExport/client/requests/DownloadReportingDataExportRequest.ts b/src/api/resources/dataExport/client/requests/DownloadReportingDataExportRequest.ts deleted file mode 100644 index 92bec12f..00000000 --- a/src/api/resources/dataExport/client/requests/DownloadReportingDataExportRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * job_identifier: "job_identifier", - * app_id: "app_id" - * } - */ -export interface DownloadReportingDataExportRequest { - job_identifier: string; - app_id: string; -} diff --git a/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts b/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts deleted file mode 100644 index 15b8c300..00000000 --- a/src/api/resources/dataExport/client/requests/ExportReportingDataRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * job_identifier: "job_identifier", - * app_id: "app_id", - * client_id: "client_id" - * } - * - * @example - * { - * job_identifier: "job_identifier", - * app_id: "app_id", - * client_id: "client_id" - * } - */ -export interface ExportReportingDataRequest { - /** Unique identifier of the job. */ - job_identifier: string; - /** The Intercom defined code of the workspace the company is associated to. */ - app_id: string; - client_id: string; -} diff --git a/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts b/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts deleted file mode 100644 index cc335ddb..00000000 --- a/src/api/resources/dataExport/client/requests/FindDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * job_identifier: "job_identifier" - * } - */ -export interface FindDataExportRequest { - /** job_identifier */ - job_identifier: string; -} diff --git a/src/api/resources/dataExport/client/requests/index.ts b/src/api/resources/dataExport/client/requests/index.ts deleted file mode 100644 index 753260ad..00000000 --- a/src/api/resources/dataExport/client/requests/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type { CancelDataExportRequest } from "./CancelDataExportRequest.js"; -export type { CreateDataExportRequest } from "./CreateDataExportRequest.js"; -export type { DownloadDataExportRequest } from "./DownloadDataExportRequest.js"; -export type { DownloadReportingDataExportRequest } from "./DownloadReportingDataExportRequest.js"; -export type { ExportReportingDataRequest } from "./ExportReportingDataRequest.js"; -export type { FindDataExportRequest } from "./FindDataExportRequest.js"; diff --git a/src/api/resources/dataExport/index.ts b/src/api/resources/dataExport/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/dataExport/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/dataExport/types/DataExport.ts b/src/api/resources/dataExport/types/DataExport.ts deleted file mode 100644 index 002d8072..00000000 --- a/src/api/resources/dataExport/types/DataExport.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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_identifier?: 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 const Status = { - Pending: "pending", - InProgress: "in_progress", - Failed: "failed", - Completed: "completed", - NoData: "no_data", - Canceled: "canceled", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts b/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts deleted file mode 100644 index 1eda3ab4..00000000 --- a/src/api/resources/dataExport/types/DataExportExportReportingDataResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface DataExportExportReportingDataResponse { - job_identifier?: string; - status?: string; - download_url?: string; - download_expires_at?: string; -} diff --git a/src/api/resources/dataExport/types/index.ts b/src/api/resources/dataExport/types/index.ts deleted file mode 100644 index 222f0cce..00000000 --- a/src/api/resources/dataExport/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataExport.js"; -export * from "./DataExportExportReportingDataResponse.js"; diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts deleted file mode 100644 index 2c645b76..00000000 --- a/src/api/resources/events/client/Client.ts +++ /dev/null @@ -1,330 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace EventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class EventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: EventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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.ListEventsRequest} request - * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.events.list({ - * user_id: "user_id", - * intercom_user_id: "intercom_user_id", - * email: "email", - * type: "type", - * summary: true, - * per_page: 1 - * }) - */ - public list( - request: Intercom.ListEventsRequest, - requestOptions?: EventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); - } - - private async __list( - request: Intercom.ListEventsRequest, - requestOptions?: EventsClient.RequestOptions, - ): Promise> { - const { - user_id: userId, - intercom_user_id: intercomUserId, - email, - type: type_, - summary, - per_page: perPage, - } = request; - const _queryParams: Record = {}; - if (userId != null) { - _queryParams.user_id = userId; - } - - if (intercomUserId != null) { - _queryParams.intercom_user_id = intercomUserId; - } - - if (email != null) { - _queryParams.email = email; - } - - _queryParams.type = type_; - if (summary != null) { - _queryParams.summary = summary.toString(); - } - - if (perPage != null) { - _queryParams.per_page = perPage.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/events"); - } - - /** - * - * 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.CreateDataEventRequest} request - * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.events.create({ - * id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - * event_name: "invited-friend", - * created_at: 1671028894 - * }) - */ - public create( - request: Intercom.CreateDataEventRequest, - requestOptions?: EventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateDataEventRequest, - requestOptions?: EventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events"); - } - - /** - * 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.ListEventSummariesRequest} request - * @param {EventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.events.summaries() - */ - public summaries( - request: Intercom.ListEventSummariesRequest = {}, - requestOptions?: EventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__summaries(request, requestOptions)); - } - - private async __summaries( - request: Intercom.ListEventSummariesRequest = {}, - requestOptions?: EventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events/summaries", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events/summaries"); - } -} diff --git a/src/api/resources/events/client/index.ts b/src/api/resources/events/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/events/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/events/client/requests/ListEventSummariesRequest.ts b/src/api/resources/events/client/requests/ListEventSummariesRequest.ts deleted file mode 100644 index 6c0d7bca..00000000 --- a/src/api/resources/events/client/requests/ListEventSummariesRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * {} - */ -export interface ListEventSummariesRequest { - /** 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?: ListEventSummariesRequest.EventSummaries; -} - -export namespace ListEventSummariesRequest { - /** - * 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/events/client/requests/ListEventsRequest.ts b/src/api/resources/events/client/requests/ListEventsRequest.ts deleted file mode 100644 index 6617f912..00000000 --- a/src/api/resources/events/client/requests/ListEventsRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * user_id: "user_id", - * intercom_user_id: "intercom_user_id", - * email: "email", - * type: "type", - * summary: true, - * per_page: 1 - * } - */ -export interface ListEventsRequest { - /** user_id query parameter */ - user_id?: string; - /** intercom_user_id query parameter */ - intercom_user_id?: string; - /** email query parameter */ - email?: string; - /** The value must be user */ - type: string; - /** summary flag */ - summary?: boolean; - /** How many results to display per page. Defaults to 15 */ - per_page?: number; -} diff --git a/src/api/resources/events/client/requests/index.ts b/src/api/resources/events/client/requests/index.ts deleted file mode 100644 index 584ea81e..00000000 --- a/src/api/resources/events/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { ListEventSummariesRequest } from "./ListEventSummariesRequest.js"; -export type { ListEventsRequest } from "./ListEventsRequest.js"; diff --git a/src/api/resources/events/index.ts b/src/api/resources/events/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/events/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/export/client/Client.ts b/src/api/resources/export/client/Client.ts deleted file mode 100644 index 521fe210..00000000 --- a/src/api/resources/export/client/Client.ts +++ /dev/null @@ -1,176 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace ExportClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class ExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ExportClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * @param {Intercom.PostExportReportingDataEnqueueRequest} request - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.TooManyRequestsError} - * - * @example - * await client.export.enqueueANewReportingDataExportJob({ - * dataset_id: "conversation", - * attribute_ids: ["conversation_id", "conversation_started_at"], - * start_time: 1717490000, - * end_time: 1717510000 - * }) - */ - public enqueueANewReportingDataExportJob( - request: Intercom.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions)); - } - - private async __enqueueANewReportingDataExportJob( - request: Intercom.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "export/reporting_data/enqueue", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.PostExportReportingDataEnqueueResponse, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 429: - throw new Intercom.TooManyRequestsError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/export/reporting_data/enqueue", - ); - } - - /** - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.export.listAvailableDatasetsAndAttributes() - */ - public listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions)); - } - - private async __listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/export/reporting_data/get_datasets", - ); - } -} diff --git a/src/api/resources/export/client/index.ts b/src/api/resources/export/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/export/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts deleted file mode 100644 index 57767a44..00000000 --- a/src/api/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * dataset_id: "conversation", - * attribute_ids: ["conversation_id", "conversation_started_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/export/client/requests/index.ts b/src/api/resources/export/client/requests/index.ts deleted file mode 100644 index a18772b7..00000000 --- a/src/api/resources/export/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { PostExportReportingDataEnqueueRequest } from "./PostExportReportingDataEnqueueRequest.js"; diff --git a/src/api/resources/export/index.ts b/src/api/resources/export/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/export/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts deleted file mode 100644 index 725ac29a..00000000 --- a/src/api/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts +++ /dev/null @@ -1,31 +0,0 @@ -// 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/export/types/PostExportReportingDataEnqueueResponse.ts b/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts deleted file mode 100644 index c15d988e..00000000 --- a/src/api/resources/export/types/PostExportReportingDataEnqueueResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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/export/types/index.ts b/src/api/resources/export/types/index.ts deleted file mode 100644 index 27e82ed3..00000000 --- a/src/api/resources/export/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./GetExportReportingDataGetDatasetsResponse.js"; -export * from "./PostExportReportingDataEnqueueResponse.js"; diff --git a/src/api/resources/helpCenter/index.ts b/src/api/resources/helpCenter/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/helpCenter/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/helpCenter/types/Collection.ts b/src/api/resources/helpCenter/types/Collection.ts deleted file mode 100644 index 7c9a53b2..00000000 --- a/src/api/resources/helpCenter/types/Collection.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.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/helpCenter/types/HelpCenter.ts b/src/api/resources/helpCenter/types/HelpCenter.ts deleted file mode 100644 index 3715e87f..00000000 --- a/src/api/resources/helpCenter/types/HelpCenter.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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; - /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ - url?: string; - /** Custom domain configured for the help center */ - custom_domain?: string; -} diff --git a/src/api/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/helpCenter/types/HelpCenterList.ts deleted file mode 100644 index e034eaff..00000000 --- a/src/api/resources/helpCenter/types/HelpCenterList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.HelpCenter[]; -} diff --git a/src/api/resources/helpCenter/types/index.ts b/src/api/resources/helpCenter/types/index.ts deleted file mode 100644 index 097e7b49..00000000 --- a/src/api/resources/helpCenter/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Collection.js"; -export * from "./HelpCenter.js"; -export * from "./HelpCenterList.js"; diff --git a/src/api/resources/helpCenters/client/Client.ts b/src/api/resources/helpCenters/client/Client.ts deleted file mode 100644 index 5541fb5c..00000000 --- a/src/api/resources/helpCenters/client/Client.ts +++ /dev/null @@ -1,199 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; -import { CollectionsClient } from "../resources/collections/client/Client.js"; - -export declare namespace HelpCentersClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class HelpCentersClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - protected _collections: CollectionsClient | undefined; - - constructor(options: HelpCentersClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - public get collections(): CollectionsClient { - return (this._collections ??= new CollectionsClient(this._options)); - } - - /** - * 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.FindHelpCenterRequest} request - * @param {HelpCentersClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.helpCenters.find({ - * help_center_id: 1 - * }) - */ - public find( - request: Intercom.FindHelpCenterRequest, - requestOptions?: HelpCentersClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindHelpCenterRequest, - requestOptions?: HelpCentersClient.RequestOptions, - ): Promise> { - const { help_center_id: helpCenterId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/help_centers/${core.url.encodePathParam(helpCenterId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/help_center/help_centers/{help_center_id}", - ); - } - - /** - * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. - * - * @param {Intercom.ListHelpCentersRequest} request - * @param {HelpCentersClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.helpCenters.list() - */ - public async list( - request: Intercom.ListHelpCentersRequest = {}, - requestOptions?: HelpCentersClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/help_centers", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/help_center/help_centers", - ); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.data ?? []).length > 0, - getItems: (response) => response?.data ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } -} diff --git a/src/api/resources/helpCenters/client/index.ts b/src/api/resources/helpCenters/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/helpCenters/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/helpCenters/client/requests/FindHelpCenterRequest.ts b/src/api/resources/helpCenters/client/requests/FindHelpCenterRequest.ts deleted file mode 100644 index f3efe0e4..00000000 --- a/src/api/resources/helpCenters/client/requests/FindHelpCenterRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * help_center_id: 1 - * } - */ -export interface FindHelpCenterRequest { - /** The unique identifier for the collection which is given by Intercom. */ - help_center_id: number; -} diff --git a/src/api/resources/helpCenters/client/requests/ListHelpCentersRequest.ts b/src/api/resources/helpCenters/client/requests/ListHelpCentersRequest.ts deleted file mode 100644 index 88dbf4b2..00000000 --- a/src/api/resources/helpCenters/client/requests/ListHelpCentersRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * {} - */ -export interface ListHelpCentersRequest { - /** 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/helpCenters/client/requests/index.ts b/src/api/resources/helpCenters/client/requests/index.ts deleted file mode 100644 index ea47193d..00000000 --- a/src/api/resources/helpCenters/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { FindHelpCenterRequest } from "./FindHelpCenterRequest.js"; -export type { ListHelpCentersRequest } from "./ListHelpCentersRequest.js"; diff --git a/src/api/resources/helpCenters/index.ts b/src/api/resources/helpCenters/index.ts deleted file mode 100644 index 9eb1192d..00000000 --- a/src/api/resources/helpCenters/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./resources/index.js"; diff --git a/src/api/resources/helpCenters/resources/collections/client/Client.ts b/src/api/resources/helpCenters/resources/collections/client/Client.ts deleted file mode 100644 index 86958a90..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/Client.ts +++ /dev/null @@ -1,439 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CollectionsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class CollectionsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CollectionsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {Intercom.helpCenters.ListCollectionsRequest} request - * @param {CollectionsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.helpCenters.collections.list() - */ - public async list( - request: Intercom.helpCenters.ListCollectionsRequest = {}, - requestOptions?: CollectionsClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/collections", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/help_center/collections", - ); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.data ?? []).length > 0, - getItems: (response) => response?.data ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } - - /** - * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` - * - * @param {Intercom.helpCenters.CreateCollectionRequest} request - * @param {CollectionsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.helpCenters.collections.create({ - * name: "Thanks for everything" - * }) - * - * @example - * await client.helpCenters.collections.create({ - * name: "collection 51", - * description: "Missing required parameter" - * }) - */ - public create( - request: Intercom.helpCenters.CreateCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.helpCenters.CreateCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/collections", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/help_center/collections"); - } - - /** - * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. - * - * @param {Intercom.helpCenters.FindCollectionRequest} request - * @param {CollectionsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.helpCenters.collections.find({ - * collection_id: 1 - * }) - */ - public find( - request: Intercom.helpCenters.FindCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.helpCenters.FindCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): Promise> { - const { collection_id: collectionId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(collectionId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/help_center/collections/{collection_id}", - ); - } - - /** - * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. - * - * @param {Intercom.helpCenters.UpdateCollectionRequest} request - * @param {CollectionsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.helpCenters.collections.update({ - * collection_id: 1, - * name: "Update collection name" - * }) - */ - public update( - request: Intercom.helpCenters.UpdateCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.helpCenters.UpdateCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): Promise> { - const { collection_id: collectionId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(collectionId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/help_center/collections/{collection_id}", - ); - } - - /** - * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. - * - * @param {Intercom.helpCenters.DeleteCollectionRequest} request - * @param {CollectionsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.helpCenters.collections.delete({ - * collection_id: 1 - * }) - */ - public delete( - request: Intercom.helpCenters.DeleteCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.helpCenters.DeleteCollectionRequest, - requestOptions?: CollectionsClient.RequestOptions, - ): Promise> { - const { collection_id: collectionId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(collectionId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/help_center/collections/{collection_id}", - ); - } -} diff --git a/src/api/resources/helpCenters/resources/collections/client/index.ts b/src/api/resources/helpCenters/resources/collections/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/helpCenters/resources/collections/client/requests/CreateCollectionRequest.ts b/src/api/resources/helpCenters/resources/collections/client/requests/CreateCollectionRequest.ts deleted file mode 100644 index 045965d9..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/CreateCollectionRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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.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/helpCenters/resources/collections/client/requests/DeleteCollectionRequest.ts b/src/api/resources/helpCenters/resources/collections/client/requests/DeleteCollectionRequest.ts deleted file mode 100644 index f97cdf86..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/DeleteCollectionRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * collection_id: 1 - * } - */ -export interface DeleteCollectionRequest { - /** The unique identifier for the collection which is given by Intercom. */ - collection_id: number; -} diff --git a/src/api/resources/helpCenters/resources/collections/client/requests/FindCollectionRequest.ts b/src/api/resources/helpCenters/resources/collections/client/requests/FindCollectionRequest.ts deleted file mode 100644 index ddf2e39b..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/FindCollectionRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * collection_id: 1 - * } - */ -export interface FindCollectionRequest { - /** The unique identifier for the collection which is given by Intercom. */ - collection_id: number; -} diff --git a/src/api/resources/helpCenters/resources/collections/client/requests/ListCollectionsRequest.ts b/src/api/resources/helpCenters/resources/collections/client/requests/ListCollectionsRequest.ts deleted file mode 100644 index 2ebe21cd..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/ListCollectionsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * {} - */ -export interface ListCollectionsRequest { - /** 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/helpCenters/resources/collections/client/requests/UpdateCollectionRequest.ts b/src/api/resources/helpCenters/resources/collections/client/requests/UpdateCollectionRequest.ts deleted file mode 100644 index 63cae012..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/UpdateCollectionRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * collection_id: 1, - * name: "Update collection name" - * } - * - * @example - * { - * collection_id: 1, - * name: "Update collection name" - * } - */ -export interface UpdateCollectionRequest { - /** The unique identifier for the collection which is given by Intercom. */ - collection_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.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/helpCenters/resources/collections/client/requests/index.ts b/src/api/resources/helpCenters/resources/collections/client/requests/index.ts deleted file mode 100644 index 83e00901..00000000 --- a/src/api/resources/helpCenters/resources/collections/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { CreateCollectionRequest } from "./CreateCollectionRequest.js"; -export type { DeleteCollectionRequest } from "./DeleteCollectionRequest.js"; -export type { FindCollectionRequest } from "./FindCollectionRequest.js"; -export type { ListCollectionsRequest } from "./ListCollectionsRequest.js"; -export type { UpdateCollectionRequest } from "./UpdateCollectionRequest.js"; diff --git a/src/api/resources/helpCenters/resources/collections/index.ts b/src/api/resources/helpCenters/resources/collections/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/helpCenters/resources/collections/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/helpCenters/resources/index.ts b/src/api/resources/helpCenters/resources/index.ts deleted file mode 100644 index a661f9d8..00000000 --- a/src/api/resources/helpCenters/resources/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./collections/client/requests/index.js"; -export * as collections from "./collections/index.js"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts deleted file mode 100644 index 716d6022..00000000 --- a/src/api/resources/index.ts +++ /dev/null @@ -1,83 +0,0 @@ -export * from "./admins/client/requests/index.js"; -export * as admins from "./admins/index.js"; -export * from "./admins/types/index.js"; -export * as aiAgent from "./aiAgent/index.js"; -export * from "./aiAgent/types/index.js"; -export * from "./aiContent/client/requests/index.js"; -export * as aiContent from "./aiContent/index.js"; -export * from "./aiContent/types/index.js"; -export * as aiContentSource from "./aiContentSource/index.js"; -export * from "./aiContentSource/types/index.js"; -export * from "./articles/client/requests/index.js"; -export * as articles from "./articles/index.js"; -export * from "./articles/types/index.js"; -export * as awayStatusReasons from "./awayStatusReasons/index.js"; -export * from "./calls/client/requests/index.js"; -export * as calls from "./calls/index.js"; -export * from "./calls/types/index.js"; -export * from "./companies/client/requests/index.js"; -export * as companies from "./companies/index.js"; -export * from "./companies/types/index.js"; -export * from "./contacts/client/requests/index.js"; -export * as contacts from "./contacts/index.js"; -export * from "./contacts/types/index.js"; -export * from "./conversations/client/requests/index.js"; -export * as conversations from "./conversations/index.js"; -export * from "./conversations/types/index.js"; -export * from "./customChannelEvents/client/requests/index.js"; -export * as customChannelEvents from "./customChannelEvents/index.js"; -export * from "./customObjectInstances/client/requests/index.js"; -export * as customObjectInstances from "./customObjectInstances/index.js"; -export * from "./customObjectInstances/types/index.js"; -export * from "./dataAttributes/client/requests/index.js"; -export * as dataAttributes from "./dataAttributes/index.js"; -export * from "./dataAttributes/types/index.js"; -export * as dataEvents from "./dataEvents/index.js"; -export * from "./dataEvents/types/index.js"; -export * from "./dataExport/client/requests/index.js"; -export * as dataExport from "./dataExport/index.js"; -export * from "./dataExport/types/index.js"; -export * from "./events/client/requests/index.js"; -export * as events from "./events/index.js"; -export * from "./export/client/requests/index.js"; -export * as export_ from "./export/index.js"; -export * from "./export/types/index.js"; -export * as helpCenter from "./helpCenter/index.js"; -export * from "./helpCenter/types/index.js"; -export * from "./helpCenters/client/requests/index.js"; -export * as helpCenters from "./helpCenters/index.js"; -export * from "./internalArticles/client/requests/index.js"; -export * as internalArticles from "./internalArticles/index.js"; -export * from "./internalArticles/types/index.js"; -export * as ipAllowlist from "./ipAllowlist/index.js"; -export * from "./jobs/client/requests/index.js"; -export * as jobs from "./jobs/index.js"; -export * from "./jobs/types/index.js"; -export * as messages from "./messages/index.js"; -export * from "./messages/types/index.js"; -export * as news from "./news/index.js"; -export * from "./news/types/index.js"; -export * from "./notes/client/requests/index.js"; -export * as notes from "./notes/index.js"; -export * from "./notes/types/index.js"; -export * as phoneCallRedirects from "./phoneCallRedirects/index.js"; -export * from "./segments/client/requests/index.js"; -export * as segments from "./segments/index.js"; -export * from "./segments/types/index.js"; -export * as subscriptionTypes from "./subscriptionTypes/index.js"; -export * from "./subscriptionTypes/types/index.js"; -export * from "./tags/client/requests/index.js"; -export * as tags from "./tags/index.js"; -export * from "./tags/types/index.js"; -export * from "./teams/client/requests/index.js"; -export * as teams from "./teams/index.js"; -export * from "./teams/types/index.js"; -export * as ticketStates from "./ticketStates/index.js"; -export * from "./tickets/client/requests/index.js"; -export * as tickets from "./tickets/index.js"; -export * from "./tickets/types/index.js"; -export * from "./ticketTypes/client/requests/index.js"; -export * as ticketTypes from "./ticketTypes/index.js"; -export * as unstable from "./unstable/index.js"; -export * from "./visitors/client/requests/index.js"; -export * as visitors from "./visitors/index.js"; diff --git a/src/api/resources/internalArticles/client/Client.ts b/src/api/resources/internalArticles/client/Client.ts deleted file mode 100644 index 4640a818..00000000 --- a/src/api/resources/internalArticles/client/Client.ts +++ /dev/null @@ -1,503 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace InternalArticlesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Internal Articles - */ -export class InternalArticlesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: InternalArticlesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. - * - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.internalArticles.listInternalArticles() - */ - public listInternalArticles( - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listInternalArticles(requestOptions)); - } - - private async __listInternalArticles( - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.InternalArticleList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/internal_articles"); - } - - /** - * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. - * - * @param {Intercom.CreateInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.internalArticles.createInternalArticle({ - * title: "Thanks for everything", - * body: "Body of the Article", - * author_id: 991266252, - * owner_id: 991266252 - * }) - * - * @example - * await client.internalArticles.createInternalArticle({ - * title: "Thanks for everything", - * body: "Body of the Internal Article", - * author_id: 1295, - * owner_id: 1295 - * }) - */ - public createInternalArticle( - request?: Intercom.CreateInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createInternalArticle(request, requestOptions)); - } - - private async __createInternalArticle( - request?: Intercom.CreateInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.InternalArticle, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/internal_articles"); - } - - /** - * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.RetrieveInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.internalArticles.retrieveInternalArticle({ - * internal_article_id: 1 - * }) - */ - public retrieveInternalArticle( - request: Intercom.RetrieveInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveInternalArticle(request, requestOptions)); - } - - private async __retrieveInternalArticle( - request: Intercom.RetrieveInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { internal_article_id: internalArticleId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(internalArticleId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.InternalArticle, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/internal_articles/{internal_article_id}", - ); - } - - /** - * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.UpdateInternalArticleRequestBody} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.internalArticles.updateInternalArticle({ - * internal_article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * }) - */ - public updateInternalArticle( - request: Intercom.UpdateInternalArticleRequestBody, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateInternalArticle(request, requestOptions)); - } - - private async __updateInternalArticle( - request: Intercom.UpdateInternalArticleRequestBody, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { internal_article_id: internalArticleId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(internalArticleId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.InternalArticle, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/internal_articles/{internal_article_id}", - ); - } - - /** - * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.DeleteInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.internalArticles.deleteInternalArticle({ - * internal_article_id: 1 - * }) - */ - public deleteInternalArticle( - request: Intercom.DeleteInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteInternalArticle(request, requestOptions)); - } - - private async __deleteInternalArticle( - request: Intercom.DeleteInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { internal_article_id: internalArticleId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(internalArticleId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.DeletedInternalArticleObject, - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/internal_articles/{internal_article_id}", - ); - } - - /** - * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. - * - * @param {Intercom.SearchInternalArticlesRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.internalArticles.searchInternalArticles({ - * folder_id: "folder_id" - * }) - */ - public searchInternalArticles( - request: Intercom.SearchInternalArticlesRequest = {}, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchInternalArticles(request, requestOptions)); - } - - private async __searchInternalArticles( - request: Intercom.SearchInternalArticlesRequest = {}, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { folder_id: folderId } = request; - const _queryParams: Record = {}; - if (folderId != null) { - _queryParams.folder_id = folderId; - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles/search", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.InternalArticleSearchResponse, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/internal_articles/search"); - } -} diff --git a/src/api/resources/internalArticles/client/index.ts b/src/api/resources/internalArticles/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/internalArticles/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts b/src/api/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts deleted file mode 100644 index 6cd2773b..00000000 --- a/src/api/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * internal_article_id: 1 - * } - */ -export interface DeleteInternalArticleRequest { - /** The unique identifier for the internal article which is given by Intercom. */ - internal_article_id: number; -} diff --git a/src/api/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts b/src/api/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts deleted file mode 100644 index ca4bac12..00000000 --- a/src/api/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * internal_article_id: 1 - * } - */ -export interface RetrieveInternalArticleRequest { - /** The unique identifier for the article which is given by Intercom. */ - internal_article_id: number; -} diff --git a/src/api/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts b/src/api/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts deleted file mode 100644 index 6f80cf05..00000000 --- a/src/api/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * folder_id: "folder_id" - * } - */ -export interface SearchInternalArticlesRequest { - /** The ID of the folder to search in. */ - folder_id?: string; -} diff --git a/src/api/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts b/src/api/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts deleted file mode 100644 index 55416491..00000000 --- a/src/api/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * internal_article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - * - * @example - * { - * internal_article_id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - */ -export interface UpdateInternalArticleRequestBody { - /** The unique identifier for the internal article which is given by Intercom. */ - internal_article_id: number; - /** The title of the article. */ - title?: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id?: number; - /** The id of the author of the article. */ - owner_id?: number; -} diff --git a/src/api/resources/internalArticles/client/requests/index.ts b/src/api/resources/internalArticles/client/requests/index.ts deleted file mode 100644 index 677bd9fa..00000000 --- a/src/api/resources/internalArticles/client/requests/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type { DeleteInternalArticleRequest } from "./DeleteInternalArticleRequest.js"; -export type { RetrieveInternalArticleRequest } from "./RetrieveInternalArticleRequest.js"; -export type { SearchInternalArticlesRequest } from "./SearchInternalArticlesRequest.js"; -export type { UpdateInternalArticleRequestBody } from "./UpdateInternalArticleRequestBody.js"; diff --git a/src/api/resources/internalArticles/index.ts b/src/api/resources/internalArticles/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/internalArticles/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/internalArticles/types/InternalArticleListItem.ts b/src/api/resources/internalArticles/types/InternalArticleListItem.ts deleted file mode 100644 index b906ff6f..00000000 --- a/src/api/resources/internalArticles/types/InternalArticleListItem.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The data returned about your internal articles when you list them. - */ -export interface InternalArticleListItem { - /** The type of object - `internal_article`. */ - type?: "internal_article"; - /** The unique identifier for the article which is given by Intercom. */ - id?: string; - /** The title of the article. */ - title?: string; - /** The body of the article in HTML. */ - body?: string; - /** The id of the owner of the article. */ - owner_id?: number; - /** The id of the author of the article. */ - author_id?: number; - /** The time when the article was created. */ - created_at?: number; - /** The time when the article was last updated. */ - updated_at?: number; - /** The default locale of the article. */ - locale?: string; -} diff --git a/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts b/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts deleted file mode 100644 index 9718b94b..00000000 --- a/src/api/resources/internalArticles/types/InternalArticleSearchResponse.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * The results of an Internal Article search - */ -export interface InternalArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Internal Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: InternalArticleSearchResponse.Data; - pages?: Intercom.CursorPages; -} - -export namespace InternalArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Internal Article objects */ - internal_articles?: Intercom.InternalArticle[]; - } -} diff --git a/src/api/resources/internalArticles/types/index.ts b/src/api/resources/internalArticles/types/index.ts deleted file mode 100644 index aedeb96e..00000000 --- a/src/api/resources/internalArticles/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./InternalArticleListItem.js"; -export * from "./InternalArticleSearchResponse.js"; diff --git a/src/api/resources/ipAllowlist/client/Client.ts b/src/api/resources/ipAllowlist/client/Client.ts deleted file mode 100644 index 21809d4b..00000000 --- a/src/api/resources/ipAllowlist/client/Client.ts +++ /dev/null @@ -1,179 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace IpAllowlistClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Manage IP allowlist settings for your workspace. - * - * The IP Allowlist API allows you to configure which IP addresses are allowed to access the Intercom API and web application for your workspace. This is useful for restricting access to your Intercom workspace to specific corporate networks or VPNs. - * - * {% admonition type="info" name="Authentication" %} - * This endpoint requires the `manage_ip_allowlist` OAuth scope. - * {% /admonition %} - */ -export class IpAllowlistClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: IpAllowlistClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve the current IP allowlist configuration for the workspace. - * - * @param {IpAllowlistClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ipAllowlist.getIpAllowlist() - */ - public getIpAllowlist( - requestOptions?: IpAllowlistClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getIpAllowlist(requestOptions)); - } - - private async __getIpAllowlist( - requestOptions?: IpAllowlistClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ip_allowlist", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.IpAllowlist, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ip_allowlist"); - } - - /** - * Update the IP allowlist configuration for the workspace. - * - * {% admonition type="warning" name="Lockout Protection" %} - * The API will reject updates that would lock out the caller's IP address. Ensure your current IP is included in the allowlist when enabling the feature. - * {% /admonition %} - * - * @param {Intercom.IpAllowlist} request - * @param {IpAllowlistClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.ipAllowlist.updateIpAllowlist({ - * enabled: true, - * ip_allowlist: ["192.168.1.0/24", "10.0.0.1"] - * }) - */ - public updateIpAllowlist( - request: Intercom.IpAllowlist, - requestOptions?: IpAllowlistClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateIpAllowlist(request, requestOptions)); - } - - private async __updateIpAllowlist( - request: Intercom.IpAllowlist, - requestOptions?: IpAllowlistClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ip_allowlist", - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.IpAllowlist, 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 422: - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/ip_allowlist"); - } -} diff --git a/src/api/resources/ipAllowlist/client/index.ts b/src/api/resources/ipAllowlist/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/ipAllowlist/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/ipAllowlist/index.ts b/src/api/resources/ipAllowlist/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/ipAllowlist/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/jobs/client/Client.ts b/src/api/resources/jobs/client/Client.ts deleted file mode 100644 index 80585eeb..00000000 --- a/src/api/resources/jobs/client/Client.ts +++ /dev/null @@ -1,101 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace JobsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about jobs - */ -export class JobsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: JobsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve the status of job execution. - * - * @param {Intercom.JobsStatusRequest} request - * @param {JobsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.jobs.status({ - * job_id: "job_id" - * }) - */ - public status( - request: Intercom.JobsStatusRequest, - requestOptions?: JobsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__status(request, requestOptions)); - } - - private async __status( - request: Intercom.JobsStatusRequest, - requestOptions?: JobsClient.RequestOptions, - ): Promise> { - const { job_id: jobId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `jobs/status/${core.url.encodePathParam(jobId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Jobs, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/jobs/status/{job_id}"); - } -} diff --git a/src/api/resources/jobs/client/index.ts b/src/api/resources/jobs/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/jobs/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/jobs/client/requests/JobsStatusRequest.ts b/src/api/resources/jobs/client/requests/JobsStatusRequest.ts deleted file mode 100644 index d5971376..00000000 --- a/src/api/resources/jobs/client/requests/JobsStatusRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * job_id: "job_id" - * } - */ -export interface JobsStatusRequest { - /** The unique identifier for the job which is given by Intercom */ - job_id: string; -} diff --git a/src/api/resources/jobs/client/requests/index.ts b/src/api/resources/jobs/client/requests/index.ts deleted file mode 100644 index bfed16f9..00000000 --- a/src/api/resources/jobs/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { JobsStatusRequest } from "./JobsStatusRequest.js"; diff --git a/src/api/resources/jobs/index.ts b/src/api/resources/jobs/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/jobs/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/jobs/types/Jobs.ts b/src/api/resources/jobs/types/Jobs.ts deleted file mode 100644 index c3e63585..00000000 --- a/src/api/resources/jobs/types/Jobs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// 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 const Status = { - Pending: "pending", - Success: "success", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/jobs/types/index.ts b/src/api/resources/jobs/types/index.ts deleted file mode 100644 index c4ca9992..00000000 --- a/src/api/resources/jobs/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Jobs.js"; diff --git a/src/api/resources/messages/client/Client.ts b/src/api/resources/messages/client/Client.ts deleted file mode 100644 index f4b5d54c..00000000 --- a/src/api/resources/messages/client/Client.ts +++ /dev/null @@ -1,184 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace MessagesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your messages - */ -export class MessagesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: MessagesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can create a message that has been initiated by an admin. The conversation can be either an in-app message or an email. - * - * > 🚧 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.CreateMessageRequest} request - * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.ForbiddenError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.messages.create({ - * message_type: "email", - * subject: "Thanks for everything", - * body: "Hello there", - * template: "plain", - * from: { - * type: "admin", - * id: 394051 - * }, - * to: { - * type: "user", - * id: "536e564f316c83104c000020" - * } - * }) - * - * @example - * await client.messages.create({ - * message_type: "inapp", - * subject: "heyy", - * body: "Hello there", - * template: "plain", - * from: { - * type: "admin", - * id: 394051 - * }, - * to: { - * type: "user", - * id: "6762f23b1bb69f9f2193bc1a" - * }, - * created_at: 1590000000, - * create_conversation_without_contact_reply: true - * }) - * - * @example - * await client.messages.create({ - * message_type: "email", - * subject: "Thanks for everything", - * body: "hey there", - * template: "plain", - * from: { - * type: "admin", - * id: 394051 - * }, - * to: { - * type: "user", - * id: "536e564f316c83104c000020" - * }, - * created_at: 1590000000, - * create_conversation_without_contact_reply: true - * }) - * - * @example - * await client.messages.create({ - * message_type: "email", - * subject: "heyy", - * body: "Hello there", - * template: "plain", - * from: { - * type: "admin", - * id: 394051 - * }, - * to: { - * type: "user", - * id: "6762f23d1bb69f9f2193bc1c" - * }, - * created_at: 1590000000, - * create_conversation_without_contact_reply: true - * }) - */ - public create( - request?: Intercom.CreateMessageRequest, - requestOptions?: MessagesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request?: Intercom.CreateMessageRequest, - requestOptions?: MessagesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "messages", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/messages"); - } -} diff --git a/src/api/resources/messages/client/index.ts b/src/api/resources/messages/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/messages/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/messages/index.ts b/src/api/resources/messages/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/messages/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/messages/types/Message.ts b/src/api/resources/messages/types/Message.ts deleted file mode 100644 index 2341594c..00000000 --- a/src/api/resources/messages/types/Message.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 or twitter. */ - 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 or twitter. */ - export const MessageType = { - Email: "email", - Inapp: "inapp", - Facebook: "facebook", - Twitter: "twitter", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/resources/messages/types/index.ts b/src/api/resources/messages/types/index.ts deleted file mode 100644 index e16d36b7..00000000 --- a/src/api/resources/messages/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Message.js"; diff --git a/src/api/resources/news/client/Client.ts b/src/api/resources/news/client/Client.ts deleted file mode 100644 index 65efc563..00000000 --- a/src/api/resources/news/client/Client.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { FeedsClient } from "../resources/feeds/client/Client.js"; -import { ItemsClient } from "../resources/items/client/Client.js"; - -export declare namespace NewsClient { - export interface Options extends BaseClientOptions {} -} - -export class NewsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - protected _items: ItemsClient | undefined; - protected _feeds: FeedsClient | undefined; - - constructor(options: NewsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - public get items(): ItemsClient { - return (this._items ??= new ItemsClient(this._options)); - } - - public get feeds(): FeedsClient { - return (this._feeds ??= new FeedsClient(this._options)); - } -} diff --git a/src/api/resources/news/client/index.ts b/src/api/resources/news/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/news/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/news/index.ts b/src/api/resources/news/index.ts deleted file mode 100644 index 0ef16e76..00000000 --- a/src/api/resources/news/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./client/index.js"; -export * from "./resources/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/news/resources/feeds/client/Client.ts b/src/api/resources/news/resources/feeds/client/Client.ts deleted file mode 100644 index b3c72e7d..00000000 --- a/src/api/resources/news/resources/feeds/client/Client.ts +++ /dev/null @@ -1,234 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace FeedsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class FeedsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: FeedsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all news items that are live on a given newsfeed - * - * @param {Intercom.news.ListNewsFeedItemsRequest} request - * @param {FeedsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.news.feeds.listItems({ - * newsfeed_id: "123" - * }) - */ - public listItems( - request: Intercom.news.ListNewsFeedItemsRequest, - requestOptions?: FeedsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listItems(request, requestOptions)); - } - - private async __listItems( - request: Intercom.news.ListNewsFeedItemsRequest, - requestOptions?: FeedsClient.RequestOptions, - ): Promise> { - const { newsfeed_id: newsfeedId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/newsfeeds/${core.url.encodePathParam(newsfeedId)}/items`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.PaginatedResponse, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/news/newsfeeds/{newsfeed_id}/items", - ); - } - - /** - * You can fetch a list of all newsfeeds - * - * @param {FeedsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.news.feeds.list() - */ - public list(requestOptions?: FeedsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: FeedsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/newsfeeds", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.PaginatedResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/newsfeeds"); - } - - /** - * You can fetch the details of a single newsfeed - * - * @param {Intercom.news.FindNewsFeedRequest} request - * @param {FeedsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.news.feeds.find({ - * newsfeed_id: "123" - * }) - */ - public find( - request: Intercom.news.FindNewsFeedRequest, - requestOptions?: FeedsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.news.FindNewsFeedRequest, - requestOptions?: FeedsClient.RequestOptions, - ): Promise> { - const { newsfeed_id: newsfeedId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/newsfeeds/${core.url.encodePathParam(newsfeedId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/newsfeeds/{newsfeed_id}"); - } -} diff --git a/src/api/resources/news/resources/feeds/client/index.ts b/src/api/resources/news/resources/feeds/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/news/resources/feeds/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/news/resources/feeds/client/requests/FindNewsFeedRequest.ts b/src/api/resources/news/resources/feeds/client/requests/FindNewsFeedRequest.ts deleted file mode 100644 index a462c8d7..00000000 --- a/src/api/resources/news/resources/feeds/client/requests/FindNewsFeedRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * newsfeed_id: "123" - * } - */ -export interface FindNewsFeedRequest { - /** The unique identifier for the news feed item which is given by Intercom. */ - newsfeed_id: string; -} diff --git a/src/api/resources/news/resources/feeds/client/requests/ListNewsFeedItemsRequest.ts b/src/api/resources/news/resources/feeds/client/requests/ListNewsFeedItemsRequest.ts deleted file mode 100644 index 5847e03b..00000000 --- a/src/api/resources/news/resources/feeds/client/requests/ListNewsFeedItemsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * newsfeed_id: "123" - * } - */ -export interface ListNewsFeedItemsRequest { - /** The unique identifier for the news feed item which is given by Intercom. */ - newsfeed_id: string; -} diff --git a/src/api/resources/news/resources/feeds/client/requests/index.ts b/src/api/resources/news/resources/feeds/client/requests/index.ts deleted file mode 100644 index c32a3ad5..00000000 --- a/src/api/resources/news/resources/feeds/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { FindNewsFeedRequest } from "./FindNewsFeedRequest.js"; -export type { ListNewsFeedItemsRequest } from "./ListNewsFeedItemsRequest.js"; diff --git a/src/api/resources/news/resources/feeds/index.ts b/src/api/resources/news/resources/feeds/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/news/resources/feeds/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/news/resources/index.ts b/src/api/resources/news/resources/index.ts deleted file mode 100644 index 631ce9c7..00000000 --- a/src/api/resources/news/resources/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./feeds/client/requests/index.js"; -export * as feeds from "./feeds/index.js"; -export * from "./items/client/requests/index.js"; -export * as items from "./items/index.js"; diff --git a/src/api/resources/news/resources/items/client/Client.ts b/src/api/resources/news/resources/items/client/Client.ts deleted file mode 100644 index 96910a6b..00000000 --- a/src/api/resources/news/resources/items/client/Client.ts +++ /dev/null @@ -1,425 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ItemsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class ItemsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ItemsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all news items - * - * @param {ItemsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.news.items.list() - */ - public list(requestOptions?: ItemsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: ItemsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/news_items", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.PaginatedResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/news_items"); - } - - /** - * You can create a news item - * - * @param {Intercom.NewsItemRequest} request - * @param {ItemsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.news.items.create({ - * 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 create( - request: Intercom.NewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.NewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/news_items", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/news/news_items"); - } - - /** - * You can fetch the details of a single news item. - * - * @param {Intercom.news.FindNewsItemRequest} request - * @param {ItemsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.news.items.find({ - * news_item_id: 1 - * }) - */ - public find( - request: Intercom.news.FindNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.news.FindNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): Promise> { - const { news_item_id: newsItemId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(newsItemId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/news/news_items/{news_item_id}", - ); - } - - /** - * @param {Intercom.news.UpdateNewsItemRequest} request - * @param {ItemsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.news.items.update({ - * news_item_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.news.items.update({ - * news_item_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 update( - request: Intercom.news.UpdateNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.news.UpdateNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): Promise> { - const { news_item_id: newsItemId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(newsItemId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/news/news_items/{news_item_id}", - ); - } - - /** - * You can delete a single news item. - * - * @param {Intercom.news.DeleteNewsItemRequest} request - * @param {ItemsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.news.items.delete({ - * news_item_id: 1 - * }) - */ - public delete( - request: Intercom.news.DeleteNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.news.DeleteNewsItemRequest, - requestOptions?: ItemsClient.RequestOptions, - ): Promise> { - const { news_item_id: newsItemId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(newsItemId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/news/news_items/{news_item_id}", - ); - } -} diff --git a/src/api/resources/news/resources/items/client/index.ts b/src/api/resources/news/resources/items/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/news/resources/items/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/news/resources/items/client/requests/DeleteNewsItemRequest.ts b/src/api/resources/news/resources/items/client/requests/DeleteNewsItemRequest.ts deleted file mode 100644 index 87c64a80..00000000 --- a/src/api/resources/news/resources/items/client/requests/DeleteNewsItemRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * news_item_id: 1 - * } - */ -export interface DeleteNewsItemRequest { - /** The unique identifier for the news item which is given by Intercom. */ - news_item_id: number; -} diff --git a/src/api/resources/news/resources/items/client/requests/FindNewsItemRequest.ts b/src/api/resources/news/resources/items/client/requests/FindNewsItemRequest.ts deleted file mode 100644 index 6e8e5ac2..00000000 --- a/src/api/resources/news/resources/items/client/requests/FindNewsItemRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * news_item_id: 1 - * } - */ -export interface FindNewsItemRequest { - /** The unique identifier for the news item which is given by Intercom. */ - news_item_id: number; -} diff --git a/src/api/resources/news/resources/items/client/requests/UpdateNewsItemRequest.ts b/src/api/resources/news/resources/items/client/requests/UpdateNewsItemRequest.ts deleted file mode 100644 index 948351c3..00000000 --- a/src/api/resources/news/resources/items/client/requests/UpdateNewsItemRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * news_item_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 - * { - * news_item_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. */ - news_item_id: number; - body: Intercom.NewsItemRequest; -} diff --git a/src/api/resources/news/resources/items/client/requests/index.ts b/src/api/resources/news/resources/items/client/requests/index.ts deleted file mode 100644 index 3869d0b3..00000000 --- a/src/api/resources/news/resources/items/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { DeleteNewsItemRequest } from "./DeleteNewsItemRequest.js"; -export type { FindNewsItemRequest } from "./FindNewsItemRequest.js"; -export type { UpdateNewsItemRequest } from "./UpdateNewsItemRequest.js"; diff --git a/src/api/resources/news/resources/items/index.ts b/src/api/resources/news/resources/items/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/news/resources/items/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/news/types/NewsItem.ts b/src/api/resources/news/types/NewsItem.ts deleted file mode 100644 index 7ae7b3f9..00000000 --- a/src/api/resources/news/types/NewsItem.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 type of object. */ - type?: "news-item"; - /** 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.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 const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/news/types/Newsfeed.ts b/src/api/resources/news/types/Newsfeed.ts deleted file mode 100644 index a42f6306..00000000 --- a/src/api/resources/news/types/Newsfeed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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 type of object. */ - type?: "newsfeed"; - /** 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/news/types/NewsfeedAssignment.ts b/src/api/resources/news/types/NewsfeedAssignment.ts deleted file mode 100644 index 064483c9..00000000 --- a/src/api/resources/news/types/NewsfeedAssignment.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/news/types/index.ts b/src/api/resources/news/types/index.ts deleted file mode 100644 index fe7a29c8..00000000 --- a/src/api/resources/news/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Newsfeed.js"; -export * from "./NewsfeedAssignment.js"; -export * from "./NewsItem.js"; diff --git a/src/api/resources/notes/client/Client.ts b/src/api/resources/notes/client/Client.ts deleted file mode 100644 index da58ae5d..00000000 --- a/src/api/resources/notes/client/Client.ts +++ /dev/null @@ -1,261 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace NotesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Notes - */ -export class NotesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: NotesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of notes that are associated to a contact. - * - * @param {Intercom.ListContactNotesRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.notes.list({ - * contact_id: "contact_id" - * }) - */ - public async list( - request: Intercom.ListContactNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/notes`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/notes", - ); - }, - ); - let _offset = request?.page != null ? request?.page : 1; - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => (response?.data ?? []).length > 0, - getItems: (response) => response?.data ?? [], - loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); - }, - }); - } - - /** - * You can add a note to a single contact. - * - * @param {Intercom.CreateContactNoteRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.notes.create({ - * contact_id: "123", - * body: "Hello", - * admin_id: "123" - * }) - */ - public create( - request: Intercom.CreateContactNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateContactNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/notes`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{contact_id}/notes"); - } - - /** - * You can fetch the details of a single note. - * - * @param {Intercom.FindNoteRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.notes.find({ - * note_id: 1 - * }) - */ - public find( - request: Intercom.FindNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { note_id: noteId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `notes/${core.url.encodePathParam(noteId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/notes/{note_id}"); - } -} diff --git a/src/api/resources/notes/client/index.ts b/src/api/resources/notes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/notes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/notes/client/requests/CreateContactNoteRequest.ts b/src/api/resources/notes/client/requests/CreateContactNoteRequest.ts deleted file mode 100644 index bff219f9..00000000 --- a/src/api/resources/notes/client/requests/CreateContactNoteRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "123", - * body: "Hello", - * admin_id: "123" - * } - * - * @example - * { - * contact_id: "123", - * body: "Hello", - * admin_id: "123" - * } - * - * @example - * { - * contact_id: "123", - * body: "Hello", - * admin_id: "123" - * } - */ -export interface CreateContactNoteRequest { - /** The unique identifier of a given contact. */ - contact_id: string; - /** The text of the note. */ - body: string; - /** The unique identifier of a given admin. */ - admin_id?: string; -} diff --git a/src/api/resources/notes/client/requests/FindNoteRequest.ts b/src/api/resources/notes/client/requests/FindNoteRequest.ts deleted file mode 100644 index c7efb6a9..00000000 --- a/src/api/resources/notes/client/requests/FindNoteRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * note_id: 1 - * } - */ -export interface FindNoteRequest { - /** The unique identifier of a given note */ - note_id: number; -} diff --git a/src/api/resources/notes/client/requests/ListContactNotesRequest.ts b/src/api/resources/notes/client/requests/ListContactNotesRequest.ts deleted file mode 100644 index 49b13673..00000000 --- a/src/api/resources/notes/client/requests/ListContactNotesRequest.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "contact_id" - * } - */ -export interface ListContactNotesRequest { - /** The unique identifier of a contact. */ - contact_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/notes/client/requests/index.ts b/src/api/resources/notes/client/requests/index.ts deleted file mode 100644 index d6e2648b..00000000 --- a/src/api/resources/notes/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { CreateContactNoteRequest } from "./CreateContactNoteRequest.js"; -export type { FindNoteRequest } from "./FindNoteRequest.js"; -export type { ListContactNotesRequest } from "./ListContactNotesRequest.js"; diff --git a/src/api/resources/notes/index.ts b/src/api/resources/notes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/notes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/notes/types/Note.ts b/src/api/resources/notes/types/Note.ts deleted file mode 100644 index 3ce14629..00000000 --- a/src/api/resources/notes/types/Note.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.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/notes/types/index.ts b/src/api/resources/notes/types/index.ts deleted file mode 100644 index e0e2f407..00000000 --- a/src/api/resources/notes/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Note.js"; diff --git a/src/api/resources/phoneCallRedirects/client/Client.ts b/src/api/resources/phoneCallRedirects/client/Client.ts deleted file mode 100644 index e2585a9f..00000000 --- a/src/api/resources/phoneCallRedirects/client/Client.ts +++ /dev/null @@ -1,119 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace PhoneCallRedirectsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class PhoneCallRedirectsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: PhoneCallRedirectsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {Intercom.CreatePhoneSwitchRequest} request - * @param {PhoneCallRedirectsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.UnprocessableEntityError} - * - * @example - * await client.phoneCallRedirects.create({ - * phone: "+353832345678", - * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" - * } - * }) - * - * @example - * await client.phoneCallRedirects.create({ - * phone: "+40241100100", - * custom_attributes: { - * "issue_type": "Billing", - * "priority": "High" - * } - * }) - */ - public create( - request?: Intercom.CreatePhoneSwitchRequest, - requestOptions?: PhoneCallRedirectsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request?: Intercom.CreatePhoneSwitchRequest, - requestOptions?: PhoneCallRedirectsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "phone_call_redirects", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.PhoneSwitch | 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, _response.rawResponse); - case 401: - throw new Intercom.UnauthorizedError( - _response.error.body as Intercom.Error_, - _response.rawResponse, - ); - case 422: - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/phone_call_redirects"); - } -} diff --git a/src/api/resources/phoneCallRedirects/client/index.ts b/src/api/resources/phoneCallRedirects/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/phoneCallRedirects/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/phoneCallRedirects/index.ts b/src/api/resources/phoneCallRedirects/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/phoneCallRedirects/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/segments/client/Client.ts b/src/api/resources/segments/client/Client.ts deleted file mode 100644 index d7073779..00000000 --- a/src/api/resources/segments/client/Client.ts +++ /dev/null @@ -1,177 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace SegmentsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Segments - */ -export class SegmentsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: SegmentsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all segments. - * - * @param {Intercom.ListSegmentsRequest} request - * @param {SegmentsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.segments.list({ - * include_count: true - * }) - */ - public list( - request: Intercom.ListSegmentsRequest = {}, - requestOptions?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); - } - - private async __list( - request: Intercom.ListSegmentsRequest = {}, - requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { - const { include_count: includeCount } = request; - const _queryParams: Record = {}; - if (includeCount != null) { - _queryParams.include_count = includeCount.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "segments", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/segments"); - } - - /** - * You can fetch the details of a single segment. - * - * @param {Intercom.FindSegmentRequest} request - * @param {SegmentsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.segments.find({ - * segment_id: "123" - * }) - */ - public find( - request: Intercom.FindSegmentRequest, - requestOptions?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindSegmentRequest, - requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { - const { segment_id: segmentId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `segments/${core.url.encodePathParam(segmentId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/segments/{segment_id}"); - } -} diff --git a/src/api/resources/segments/client/index.ts b/src/api/resources/segments/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/segments/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/segments/client/requests/FindSegmentRequest.ts b/src/api/resources/segments/client/requests/FindSegmentRequest.ts deleted file mode 100644 index eb150f95..00000000 --- a/src/api/resources/segments/client/requests/FindSegmentRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * segment_id: "123" - * } - */ -export interface FindSegmentRequest { - /** The unique identified of a given segment. */ - segment_id: string; -} diff --git a/src/api/resources/segments/client/requests/ListSegmentsRequest.ts b/src/api/resources/segments/client/requests/ListSegmentsRequest.ts deleted file mode 100644 index 7554f000..00000000 --- a/src/api/resources/segments/client/requests/ListSegmentsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * include_count: true - * } - */ -export interface ListSegmentsRequest { - /** It includes the count of contacts that belong to each segment. */ - include_count?: boolean; -} diff --git a/src/api/resources/segments/client/requests/index.ts b/src/api/resources/segments/client/requests/index.ts deleted file mode 100644 index 851720dd..00000000 --- a/src/api/resources/segments/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { FindSegmentRequest } from "./FindSegmentRequest.js"; -export type { ListSegmentsRequest } from "./ListSegmentsRequest.js"; diff --git a/src/api/resources/segments/index.ts b/src/api/resources/segments/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/segments/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/segments/types/Segment.ts b/src/api/resources/segments/types/Segment.ts deleted file mode 100644 index 5fbb6b53..00000000 --- a/src/api/resources/segments/types/Segment.ts +++ /dev/null @@ -1,30 +0,0 @@ -// 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 const PersonType = { - Contact: "contact", - User: "user", - } as const; - export type PersonType = (typeof PersonType)[keyof typeof PersonType]; -} diff --git a/src/api/resources/segments/types/index.ts b/src/api/resources/segments/types/index.ts deleted file mode 100644 index a934b01a..00000000 --- a/src/api/resources/segments/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Segment.js"; diff --git a/src/api/resources/subscriptionTypes/client/Client.ts b/src/api/resources/subscriptionTypes/client/Client.ts deleted file mode 100644 index 3f0c2673..00000000 --- a/src/api/resources/subscriptionTypes/client/Client.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace SubscriptionTypesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about subscription types - */ -export class SubscriptionTypesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: SubscriptionTypesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can list all subscription types. A list of subscription type objects will be returned. - * - * @param {SubscriptionTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.subscriptionTypes.list() - */ - public list( - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "subscription_types", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/subscription_types"); - } -} diff --git a/src/api/resources/subscriptionTypes/client/index.ts b/src/api/resources/subscriptionTypes/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/subscriptionTypes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/subscriptionTypes/index.ts b/src/api/resources/subscriptionTypes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/subscriptionTypes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/subscriptionTypes/types/SubscriptionType.ts b/src/api/resources/subscriptionTypes/types/SubscriptionType.ts deleted file mode 100644 index 55372879..00000000 --- a/src/api/resources/subscriptionTypes/types/SubscriptionType.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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?: "subscription"; - /** The unique identifier representing the subscription type. */ - id?: string; - /** The state of the subscription type. */ - state?: SubscriptionType.State; - default_translation?: Intercom.Translation; - /** An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ - translations?: Intercom.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 const State = { - Live: "live", - Draft: "draft", - Archived: "archived", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** Describes the type of consent. */ - export const ConsentType = { - OptOut: "opt_out", - OptIn: "opt_in", - } as const; - export type ConsentType = (typeof ConsentType)[keyof typeof ConsentType]; - export type ContentTypes = ContentTypes.Item[]; - - export namespace ContentTypes { - export const Item = { - Email: "email", - SmsMessage: "sms_message", - } as const; - export type Item = (typeof Item)[keyof typeof Item]; - } -} diff --git a/src/api/resources/subscriptionTypes/types/index.ts b/src/api/resources/subscriptionTypes/types/index.ts deleted file mode 100644 index b6a27359..00000000 --- a/src/api/resources/subscriptionTypes/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./SubscriptionType.js"; diff --git a/src/api/resources/tags/client/Client.ts b/src/api/resources/tags/client/Client.ts deleted file mode 100644 index 33235bf3..00000000 --- a/src/api/resources/tags/client/Client.ts +++ /dev/null @@ -1,848 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace TagsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about tags - */ -export class TagsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TagsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. - * - * @param {Intercom.TagContactRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.tagContact({ - * contact_id: "63a07ddf05a32042dffac965", - * id: "7522907" - * }) - * - * @example - * await client.tags.tagContact({ - * contact_id: "63a07ddf05a32042dffac965", - * id: "123" - * }) - */ - public tagContact( - request: Intercom.TagContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__tagContact(request, requestOptions)); - } - - private async __tagContact( - request: Intercom.TagContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{contact_id}/tags"); - } - - /** - * 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.UntagContactRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.untagContact({ - * contact_id: "63a07ddf05a32042dffac965", - * tag_id: "7522907" - * }) - */ - public untagContact( - request: Intercom.UntagContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__untagContact(request, requestOptions)); - } - - private async __untagContact( - request: Intercom.UntagContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, tag_id: tagId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags/${core.url.encodePathParam(tagId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/tags/{tag_id}", - ); - } - - /** - * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. - * - * @param {Intercom.TagConversationRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.tagConversation({ - * conversation_id: "64619700005694", - * id: "7522907", - * admin_id: "780" - * }) - */ - public tagConversation( - request: Intercom.TagConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__tagConversation(request, requestOptions)); - } - - private async __tagConversation( - request: Intercom.TagConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/tags", - ); - } - - /** - * 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.UntagConversationRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.untagConversation({ - * conversation_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * }) - */ - public untagConversation( - request: Intercom.UntagConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__untagConversation(request, requestOptions)); - } - - private async __untagConversation( - request: Intercom.UntagConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, tag_id: tagId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/tags/${core.url.encodePathParam(tagId)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}/tags/{tag_id}", - ); - } - - /** - * You can fetch a list of all tags for a given workspace. - * - * - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.tags.list() - */ - public list(requestOptions?: TagsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list(requestOptions?: TagsClient.RequestOptions): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tags", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tags"); - } - - /** - * 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.TagsCreateRequestBody} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.create({ - * name: "test" - * }) - * - * @example - * await client.tags.create({ - * name: "Independent" - * }) - * - * @example - * await client.tags.create({ - * name: "test", - * companies: [{ - * company_id: "123" - * }] - * }) - * - * @example - * await client.tags.create({ - * name: "test", - * users: [{ - * id: "123" - * }] - * }) - */ - public create( - request: Intercom.TagsCreateRequestBody, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.TagsCreateRequestBody, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tags", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tags"); - } - - /** - * You can fetch the details of tags that are on the workspace by their id. - * This will return a tag object. - * - * @param {Intercom.FindTagRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.find({ - * tag_id: "123" - * }) - */ - public find( - request: Intercom.FindTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { tag_id: tagId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tags/${core.url.encodePathParam(tagId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tags/{tag_id}"); - } - - /** - * You can delete the details of tags that are on the workspace by passing in the id. - * - * @param {Intercom.DeleteTagRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.delete({ - * tag_id: "123" - * }) - */ - public delete( - request: Intercom.DeleteTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); - } - - private async __delete( - request: Intercom.DeleteTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { tag_id: tagId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tags/${core.url.encodePathParam(tagId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/tags/{tag_id}"); - } - - /** - * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. - * - * @param {Intercom.TagTicketRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.tagTicket({ - * ticket_id: "64619700005694", - * id: "7522907", - * admin_id: "780" - * }) - */ - public tagTicket( - request: Intercom.TagTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__tagTicket(request, requestOptions)); - } - - private async __tagTicket( - request: Intercom.TagTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/{ticket_id}/tags"); - } - - /** - * 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.UntagTicketRequest} request - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tags.untagTicket({ - * ticket_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * }) - */ - public untagTicket( - request: Intercom.UntagTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__untagTicket(request, requestOptions)); - } - - private async __untagTicket( - request: Intercom.UntagTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, tag_id: tagId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}/tags/${core.url.encodePathParam(tagId)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/tickets/{ticket_id}/tags/{tag_id}", - ); - } -} diff --git a/src/api/resources/tags/client/index.ts b/src/api/resources/tags/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/tags/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/tags/client/requests/DeleteTagRequest.ts b/src/api/resources/tags/client/requests/DeleteTagRequest.ts deleted file mode 100644 index 4e81f7e4..00000000 --- a/src/api/resources/tags/client/requests/DeleteTagRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * tag_id: "123" - * } - */ -export interface DeleteTagRequest { - /** The unique identifier of a given tag */ - tag_id: string; -} diff --git a/src/api/resources/tags/client/requests/FindTagRequest.ts b/src/api/resources/tags/client/requests/FindTagRequest.ts deleted file mode 100644 index 89b19db8..00000000 --- a/src/api/resources/tags/client/requests/FindTagRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * tag_id: "123" - * } - */ -export interface FindTagRequest { - /** The unique identifier of a given tag */ - tag_id: string; -} diff --git a/src/api/resources/tags/client/requests/TagContactRequest.ts b/src/api/resources/tags/client/requests/TagContactRequest.ts deleted file mode 100644 index a9dd6aa2..00000000 --- a/src/api/resources/tags/client/requests/TagContactRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 TagContactRequest { - /** 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/tags/client/requests/TagConversationRequest.ts b/src/api/resources/tags/client/requests/TagConversationRequest.ts deleted file mode 100644 index 1a744067..00000000 --- a/src/api/resources/tags/client/requests/TagConversationRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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 TagConversationRequest { - /** 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/tags/client/requests/TagTicketRequest.ts b/src/api/resources/tags/client/requests/TagTicketRequest.ts deleted file mode 100644 index 6835d0db..00000000 --- a/src/api/resources/tags/client/requests/TagTicketRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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 TagTicketRequest { - /** 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/tags/client/requests/UntagContactRequest.ts b/src/api/resources/tags/client/requests/UntagContactRequest.ts deleted file mode 100644 index 27108640..00000000 --- a/src/api/resources/tags/client/requests/UntagContactRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * contact_id: "63a07ddf05a32042dffac965", - * tag_id: "7522907" - * } - */ -export interface UntagContactRequest { - /** 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 */ - tag_id: string; -} diff --git a/src/api/resources/tags/client/requests/UntagConversationRequest.ts b/src/api/resources/tags/client/requests/UntagConversationRequest.ts deleted file mode 100644 index bcf4e945..00000000 --- a/src/api/resources/tags/client/requests/UntagConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - * - * @example - * { - * conversation_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - * - * @example - * { - * conversation_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - */ -export interface UntagConversationRequest { - /** conversation_id */ - conversation_id: string; - /** tag_id */ - tag_id: string; - /** The unique identifier for the admin which is given by Intercom. */ - admin_id: string; -} diff --git a/src/api/resources/tags/client/requests/UntagTicketRequest.ts b/src/api/resources/tags/client/requests/UntagTicketRequest.ts deleted file mode 100644 index d6063ea7..00000000 --- a/src/api/resources/tags/client/requests/UntagTicketRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - * - * @example - * { - * ticket_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - * - * @example - * { - * ticket_id: "64619700005694", - * tag_id: "7522907", - * admin_id: "123" - * } - */ -export interface UntagTicketRequest { - /** ticket_id */ - ticket_id: string; - /** The unique identifier for the tag which is given by Intercom */ - tag_id: string; - /** The unique identifier for the admin which is given by Intercom. */ - admin_id: string; -} diff --git a/src/api/resources/tags/client/requests/index.ts b/src/api/resources/tags/client/requests/index.ts deleted file mode 100644 index f924d8ba..00000000 --- a/src/api/resources/tags/client/requests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type { DeleteTagRequest } from "./DeleteTagRequest.js"; -export type { FindTagRequest } from "./FindTagRequest.js"; -export type { TagContactRequest } from "./TagContactRequest.js"; -export type { TagConversationRequest } from "./TagConversationRequest.js"; -export type { TagTicketRequest } from "./TagTicketRequest.js"; -export type { UntagContactRequest } from "./UntagContactRequest.js"; -export type { UntagConversationRequest } from "./UntagConversationRequest.js"; -export type { UntagTicketRequest } from "./UntagTicketRequest.js"; diff --git a/src/api/resources/tags/index.ts b/src/api/resources/tags/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/tags/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/tags/types/Tag.ts b/src/api/resources/tags/types/Tag.ts deleted file mode 100644 index 3a2c7940..00000000 --- a/src/api/resources/tags/types/Tag.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A tag allows you to label your contacts, companies, and conversations and list them using that tag. - */ -export interface Tag { - /** value is "tag" */ - type: "tag"; - /** 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.Reference; -} diff --git a/src/api/resources/tags/types/TagBasic.ts b/src/api/resources/tags/types/TagBasic.ts deleted file mode 100644 index 8e8b815d..00000000 --- a/src/api/resources/tags/types/TagBasic.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/tags/types/TagsCreateRequestBody.ts b/src/api/resources/tags/types/TagsCreateRequestBody.ts deleted file mode 100644 index 3858b435..00000000 --- a/src/api/resources/tags/types/TagsCreateRequestBody.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type TagsCreateRequestBody = - | Intercom.CreateOrUpdateTagRequest - | Intercom.TagCompanyRequest - | Intercom.UntagCompanyRequest - | Intercom.TagMultipleUsersRequest; diff --git a/src/api/resources/tags/types/index.ts b/src/api/resources/tags/types/index.ts deleted file mode 100644 index 9a358541..00000000 --- a/src/api/resources/tags/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Tag.js"; -export * from "./TagBasic.js"; -export * from "./TagsCreateRequestBody.js"; diff --git a/src/api/resources/teams/client/Client.ts b/src/api/resources/teams/client/Client.ts deleted file mode 100644 index 13d8921e..00000000 --- a/src/api/resources/teams/client/Client.ts +++ /dev/null @@ -1,164 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace TeamsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Teams - */ -export class TeamsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TeamsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * This will return a list of team objects for the App. - * - * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.teams.list() - */ - public list(requestOptions?: TeamsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "teams", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams"); - } - - /** - * You can fetch the details of a single team, containing an array of admins that belong to this team. - * - * @param {Intercom.FindTeamRequest} request - * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.teams.find({ - * team_id: "123" - * }) - */ - public find( - request: Intercom.FindTeamRequest, - requestOptions?: TeamsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindTeamRequest, - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { - const { team_id: teamId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `teams/${core.url.encodePathParam(teamId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams/{team_id}"); - } -} diff --git a/src/api/resources/teams/client/index.ts b/src/api/resources/teams/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/teams/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/teams/client/requests/FindTeamRequest.ts b/src/api/resources/teams/client/requests/FindTeamRequest.ts deleted file mode 100644 index 8902bc93..00000000 --- a/src/api/resources/teams/client/requests/FindTeamRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * team_id: "123" - * } - */ -export interface FindTeamRequest { - /** The unique identifier of a given team. */ - team_id: string; -} diff --git a/src/api/resources/teams/client/requests/index.ts b/src/api/resources/teams/client/requests/index.ts deleted file mode 100644 index 0cc78a95..00000000 --- a/src/api/resources/teams/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { FindTeamRequest } from "./FindTeamRequest.js"; diff --git a/src/api/resources/teams/index.ts b/src/api/resources/teams/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/teams/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/teams/types/Team.ts b/src/api/resources/teams/types/Team.ts deleted file mode 100644 index 8b038649..00000000 --- a/src/api/resources/teams/types/Team.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.AdminPriorityLevel; - /** The assignment limit for the team. This field is only present when the team's distribution type is load balanced. */ - assignment_limit?: number; - /** Describes how assignments are distributed among the team members */ - distribution_method?: string; -} diff --git a/src/api/resources/teams/types/index.ts b/src/api/resources/teams/types/index.ts deleted file mode 100644 index bc100e99..00000000 --- a/src/api/resources/teams/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Team.js"; diff --git a/src/api/resources/ticketStates/client/Client.ts b/src/api/resources/ticketStates/client/Client.ts deleted file mode 100644 index 58ed8ebf..00000000 --- a/src/api/resources/ticketStates/client/Client.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace TicketStatesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your ticket states - */ -export class TicketStatesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketStatesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can get a list of all ticket states for a workspace. - * - * @param {TicketStatesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketStates.listTicketStates() - */ - public listTicketStates( - requestOptions?: TicketStatesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTicketStates(requestOptions)); - } - - private async __listTicketStates( - requestOptions?: TicketStatesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_states", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.TicketStateList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ticket_states"); - } -} diff --git a/src/api/resources/ticketStates/client/index.ts b/src/api/resources/ticketStates/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/ticketStates/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/ticketStates/index.ts b/src/api/resources/ticketStates/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/ticketStates/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/ticketTypes/client/Client.ts b/src/api/resources/ticketTypes/client/Client.ts deleted file mode 100644 index 8649ba80..00000000 --- a/src/api/resources/ticketTypes/client/Client.ts +++ /dev/null @@ -1,337 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; -import { AttributesClient } from "../resources/attributes/client/Client.js"; - -export declare namespace TicketTypesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your ticket types - */ -export class TicketTypesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - protected _attributes: AttributesClient | undefined; - - constructor(options: TicketTypesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - public get attributes(): AttributesClient { - return (this._attributes ??= new AttributesClient(this._options)); - } - - /** - * You can get a list of all ticket types for a workspace. - * - * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.list() - */ - public list(requestOptions?: TicketTypesClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_types", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ticket_types"); - } - - /** - * 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 {Intercom.CreateTicketTypeRequest} request - * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.create({ - * name: "Customer Issue", - * description: "Customer Report Template", - * category: "Customer", - * icon: "\uD83C\uDF9F\uFE0F" - * }) - */ - public create( - request?: Intercom.CreateTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request?: Intercom.CreateTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_types", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.TicketType | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ticket_types"); - } - - /** - * You can fetch the details of a single ticket type. - * - * @param {Intercom.FindTicketTypeRequest} request - * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.get({ - * ticket_type_id: "ticket_type_id" - * }) - */ - public get( - request: Intercom.FindTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); - } - - private async __get( - request: Intercom.FindTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.TicketType | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/ticket_types/{ticket_type_id}", - ); - } - - /** - * - * You can update a ticket type. - * - * > 📘 Updating a ticket type. - * > - * > For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) - * - * @param {Intercom.UpdateTicketTypeRequest} request - * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.update({ - * ticket_type_id: "ticket_type_id", - * name: "Bug Report 2" - * }) - */ - public update( - request: Intercom.UpdateTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.TicketType | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/ticket_types/{ticket_type_id}", - ); - } -} diff --git a/src/api/resources/ticketTypes/client/index.ts b/src/api/resources/ticketTypes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/ticketTypes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/ticketTypes/client/requests/FindTicketTypeRequest.ts b/src/api/resources/ticketTypes/client/requests/FindTicketTypeRequest.ts deleted file mode 100644 index 84a6e0ef..00000000 --- a/src/api/resources/ticketTypes/client/requests/FindTicketTypeRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_type_id: "ticket_type_id" - * } - */ -export interface FindTicketTypeRequest { - /** The unique identifier for the ticket type which is given by Intercom. */ - ticket_type_id: string; -} diff --git a/src/api/resources/ticketTypes/client/requests/UpdateTicketTypeRequest.ts b/src/api/resources/ticketTypes/client/requests/UpdateTicketTypeRequest.ts deleted file mode 100644 index 1d2bd489..00000000 --- a/src/api/resources/ticketTypes/client/requests/UpdateTicketTypeRequest.ts +++ /dev/null @@ -1,35 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_type_id: "ticket_type_id", - * name: "Bug Report 2" - * } - */ -export interface UpdateTicketTypeRequest { - /** The unique identifier for the ticket type which is given by Intercom. */ - ticket_type_id: string; - /** The name of the ticket type. */ - name?: string; - /** The description of the ticket type. */ - description?: string; - /** Category of the Ticket Type. */ - category?: UpdateTicketTypeRequest.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 UpdateTicketTypeRequest { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/ticketTypes/client/requests/index.ts b/src/api/resources/ticketTypes/client/requests/index.ts deleted file mode 100644 index 8eee27c4..00000000 --- a/src/api/resources/ticketTypes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { FindTicketTypeRequest } from "./FindTicketTypeRequest.js"; -export type { UpdateTicketTypeRequest } from "./UpdateTicketTypeRequest.js"; diff --git a/src/api/resources/ticketTypes/index.ts b/src/api/resources/ticketTypes/index.ts deleted file mode 100644 index 9eb1192d..00000000 --- a/src/api/resources/ticketTypes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./resources/index.js"; diff --git a/src/api/resources/ticketTypes/resources/attributes/client/Client.ts b/src/api/resources/ticketTypes/resources/attributes/client/Client.ts deleted file mode 100644 index 0f27dcd1..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/client/Client.ts +++ /dev/null @@ -1,194 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace AttributesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class AttributesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AttributesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can create a new attribute for a ticket type. - * - * @param {Intercom.ticketTypes.CreateTicketTypeAttributeRequest} request - * @param {AttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.attributes.create({ - * ticket_type_id: "ticket_type_id", - * name: "Attribute Title", - * description: "Attribute Description", - * data_type: "string", - * required_to_create: false - * }) - */ - public create( - request: Intercom.ticketTypes.CreateTicketTypeAttributeRequest, - requestOptions?: AttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.ticketTypes.CreateTicketTypeAttributeRequest, - requestOptions?: AttributesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}/attributes`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.TicketTypeAttribute | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/ticket_types/{ticket_type_id}/attributes", - ); - } - - /** - * You can update an existing attribute for a ticket type. - * - * @param {Intercom.ticketTypes.UpdateTicketTypeAttributeRequest} request - * @param {AttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.ticketTypes.attributes.update({ - * ticket_type_id: "ticket_type_id", - * attribute_id: "attribute_id", - * description: "New Attribute Description" - * }) - */ - public update( - request: Intercom.ticketTypes.UpdateTicketTypeAttributeRequest, - requestOptions?: AttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.ticketTypes.UpdateTicketTypeAttributeRequest, - requestOptions?: AttributesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId, attribute_id: attributeId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}/attributes/${core.url.encodePathParam(attributeId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.TicketTypeAttribute | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/ticket_types/{ticket_type_id}/attributes/{attribute_id}", - ); - } -} diff --git a/src/api/resources/ticketTypes/resources/attributes/client/index.ts b/src/api/resources/ticketTypes/resources/attributes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/ticketTypes/resources/attributes/client/requests/CreateTicketTypeAttributeRequest.ts b/src/api/resources/ticketTypes/resources/attributes/client/requests/CreateTicketTypeAttributeRequest.ts deleted file mode 100644 index 6dbf0ac2..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/client/requests/CreateTicketTypeAttributeRequest.ts +++ /dev/null @@ -1,50 +0,0 @@ -// 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 const DataType = { - String: "string", - List: "list", - Integer: "integer", - Decimal: "decimal", - Boolean: "boolean", - Datetime: "datetime", - Files: "files", - } as const; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/resources/ticketTypes/resources/attributes/client/requests/UpdateTicketTypeAttributeRequest.ts b/src/api/resources/ticketTypes/resources/attributes/client/requests/UpdateTicketTypeAttributeRequest.ts deleted file mode 100644 index 8fda5439..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/client/requests/UpdateTicketTypeAttributeRequest.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_type_id: "ticket_type_id", - * attribute_id: "attribute_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. */ - attribute_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/ticketTypes/resources/attributes/client/requests/index.ts b/src/api/resources/ticketTypes/resources/attributes/client/requests/index.ts deleted file mode 100644 index 2a2ffb63..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { CreateTicketTypeAttributeRequest } from "./CreateTicketTypeAttributeRequest.js"; -export type { UpdateTicketTypeAttributeRequest } from "./UpdateTicketTypeAttributeRequest.js"; diff --git a/src/api/resources/ticketTypes/resources/attributes/index.ts b/src/api/resources/ticketTypes/resources/attributes/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/ticketTypes/resources/attributes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/ticketTypes/resources/index.ts b/src/api/resources/ticketTypes/resources/index.ts deleted file mode 100644 index f11460cf..00000000 --- a/src/api/resources/ticketTypes/resources/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./attributes/client/requests/index.js"; -export * as attributes from "./attributes/index.js"; diff --git a/src/api/resources/tickets/client/Client.ts b/src/api/resources/tickets/client/Client.ts deleted file mode 100644 index d7456f7f..00000000 --- a/src/api/resources/tickets/client/Client.ts +++ /dev/null @@ -1,712 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace TicketsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your tickets - */ -export class TicketsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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.ReplyToTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tickets.reply({ - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2971bb69f9f2193bc49" - * } - * }) - * - * @example - * await client.tickets.reply({ - * ticket_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.tickets.reply({ - * ticket_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.tickets.reply({ - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2a41bb69f9f2193bc4c" - * } - * }) - */ - public reply( - request: Intercom.ReplyToTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__reply(request, requestOptions)); - } - - private async __reply( - request: Intercom.ReplyToTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}/reply`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/{ticket_id}/reply"); - } - - /** - * You can create a new ticket. - * - * @param {Intercom.CreateTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.tickets.create({ - * ticket_type_id: "1234", - * contacts: [{ - * id: "6762f2d81bb69f9f2193bc54" - * }] - * }) - */ - public create( - request: Intercom.CreateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Intercom.CreateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Ticket | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets"); - } - - /** - * 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.EnqueueCreateTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.tickets.enqueueCreateTicket({ - * ticket_type_id: "1234", - * contacts: [{ - * id: "6762f2d81bb69f9f2193bc54" - * }] - * }) - */ - public enqueueCreateTicket( - request: Intercom.EnqueueCreateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__enqueueCreateTicket(request, requestOptions)); - } - - private async __enqueueCreateTicket( - request: Intercom.EnqueueCreateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets/enqueue", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Jobs, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/enqueue"); - } - - /** - * You can fetch the details of a single ticket. - * - * @param {Intercom.FindTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.tickets.get({ - * ticket_id: "ticket_id" - * }) - */ - public get( - request: Intercom.FindTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); - } - - private async __get( - request: Intercom.FindTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Ticket | 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tickets/{ticket_id}"); - } - - /** - * You can update a ticket. - * - * @param {Intercom.UpdateTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.BadRequestError} - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tickets.update({ - * ticket_id: "ticket_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.tickets.update({ - * ticket_id: "ticket_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.tickets.update({ - * ticket_id: "ticket_id", - * ticket_state_id: "123" - * }) - */ - public update( - request: Intercom.UpdateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Ticket | 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, _response.rawResponse); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/tickets/{ticket_id}"); - } - - /** - * You can delete a ticket using the Intercom provided ID. - * - * @param {Intercom.DeleteTicketRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.tickets.deleteTicket({ - * ticket_id: "ticket_id" - * }) - */ - public deleteTicket( - request: Intercom.DeleteTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteTicket(request, requestOptions)); - } - - private async __deleteTicket( - request: Intercom.DeleteTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.DeleteTicketResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/tickets/{ticket_id}"); - } - - /** - * 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) | - * | title | String | - * | 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 | - * - * {% admonition type="info" name="Searching by Category" %} - * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: - * * For **Customer** category tickets, use the term `request`. - * * For **Back-office** category tickets, use the term `task`. - * * For **Tracker** category tickets, use the term `tracker`. - * {% /admonition %} - * - * ### Accepted Operators - * - * {% admonition type="info" name="Searching based on `created_at`" %} - * 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.SearchRequest} request - * @param {TicketsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.tickets.search({ - * query: { - * operator: "AND", - * value: [{ - * field: "created_at", - * operator: ">", - * value: "1306054154" - * }] - * }, - * pagination: { - * per_page: 5 - * } - * }) - */ - public async search( - request: Intercom.SearchRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const list = core.HttpResponsePromise.interceptFunction( - async (request: Intercom.SearchRequest): Promise> => { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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.body, - rawResponse: _response.rawResponse, - }); - } - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/search"); - }, - ); - const dataWithRawResponse = await list(request).withRawResponse(); - return new core.Page({ - response: dataWithRawResponse.data, - rawResponse: dataWithRawResponse.rawResponse, - hasNextPage: (response) => - response?.pages?.next?.starting_after != null && - !( - typeof response?.pages?.next?.starting_after === "string" && - response?.pages?.next?.starting_after === "" - ), - getItems: (response) => response?.tickets ?? [], - loadPage: (response) => { - return list( - core.setObjectProperty(request, "pagination.starting_after", response?.pages?.next?.starting_after), - ); - }, - }); - } -} diff --git a/src/api/resources/tickets/client/index.ts b/src/api/resources/tickets/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/tickets/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/tickets/client/requests/CreateTicketRequest.ts b/src/api/resources/tickets/client/requests/CreateTicketRequest.ts deleted file mode 100644 index 496df31d..00000000 --- a/src/api/resources/tickets/client/requests/CreateTicketRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * ticket_type_id: "1234", - * contacts: [{ - * id: "6762f2d81bb69f9f2193bc54" - * }] - * } - */ -export interface CreateTicketRequest extends Intercom.CreateTicketRequestBody { - /** Option to disable notifications when a Ticket is created. */ - skip_notifications?: boolean; -} diff --git a/src/api/resources/tickets/client/requests/DeleteTicketRequest.ts b/src/api/resources/tickets/client/requests/DeleteTicketRequest.ts deleted file mode 100644 index e5b5dee8..00000000 --- a/src/api/resources/tickets/client/requests/DeleteTicketRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_id: "ticket_id" - * } - */ -export interface DeleteTicketRequest { - /** The unique identifier for the ticket which is given by Intercom. */ - ticket_id: string; -} diff --git a/src/api/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts b/src/api/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts deleted file mode 100644 index f7969901..00000000 --- a/src/api/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * ticket_type_id: "1234", - * contacts: [{ - * id: "6762f2d81bb69f9f2193bc54" - * }] - * } - */ -export interface EnqueueCreateTicketRequest extends Intercom.CreateTicketRequestBody { - /** Option to disable notifications when a Ticket is created. */ - skip_notifications?: boolean; -} diff --git a/src/api/resources/tickets/client/requests/FindTicketRequest.ts b/src/api/resources/tickets/client/requests/FindTicketRequest.ts deleted file mode 100644 index f3f1e814..00000000 --- a/src/api/resources/tickets/client/requests/FindTicketRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_id: "ticket_id" - * } - */ -export interface FindTicketRequest { - /** The unique identifier for the ticket which is given by Intercom. */ - ticket_id: string; -} diff --git a/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts b/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts deleted file mode 100644 index b67d7011..00000000 --- a/src/api/resources/tickets/client/requests/ReplyToTicketRequest.ts +++ /dev/null @@ -1,81 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../index.js"; - -/** - * @example - * { - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2971bb69f9f2193bc49" - * } - * } - * - * @example - * { - * ticket_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 - * { - * ticket_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 - * { - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2a41bb69f9f2193bc4c" - * } - * } - * - * @example - * { - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2971bb69f9f2193bc49" - * } - * } - * - * @example - * { - * ticket_id: "123", - * body: { - * message_type: "comment", - * type: "user", - * body: "Thanks again :)", - * intercom_user_id: "6762f2971bb69f9f2193bc49" - * } - * } - */ -export interface ReplyToTicketRequest { - ticket_id: string; - body: Intercom.TicketsReplyRequestBody; -} diff --git a/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts b/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts deleted file mode 100644 index 7ba6219a..00000000 --- a/src/api/resources/tickets/client/requests/UpdateTicketRequest.ts +++ /dev/null @@ -1,67 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ticket_id: "ticket_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 - * { - * ticket_id: "ticket_id", - * ticket_attributes: { - * "_default_title_": "example", - * "_default_description_": "there is a problem" - * }, - * ticket_state_id: "123", - * admin_id: 991268011, - * assignee_id: "123" - * } - * - * @example - * { - * ticket_id: "ticket_id", - * ticket_attributes: { - * "_default_title_": "example", - * "_default_description_": "there is a problem" - * }, - * ticket_state_id: "123", - * admin_id: 991268011, - * assignee_id: "123" - * } - * - * @example - * { - * ticket_id: "ticket_id", - * ticket_state_id: "123" - * } - */ -export interface UpdateTicketRequest { - /** The unique identifier for the ticket which is given by Intercom */ - ticket_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/tickets/client/requests/index.ts b/src/api/resources/tickets/client/requests/index.ts deleted file mode 100644 index 2a2313d7..00000000 --- a/src/api/resources/tickets/client/requests/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export type { CreateTicketRequest } from "./CreateTicketRequest.js"; -export type { DeleteTicketRequest } from "./DeleteTicketRequest.js"; -export type { EnqueueCreateTicketRequest } from "./EnqueueCreateTicketRequest.js"; -export type { FindTicketRequest } from "./FindTicketRequest.js"; -export type { ReplyToTicketRequest } from "./ReplyToTicketRequest.js"; -export type { UpdateTicketRequest } from "./UpdateTicketRequest.js"; diff --git a/src/api/resources/tickets/index.ts b/src/api/resources/tickets/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/tickets/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/tickets/types/DeleteTicketResponse.ts b/src/api/resources/tickets/types/DeleteTicketResponse.ts deleted file mode 100644 index cdad7f2d..00000000 --- a/src/api/resources/tickets/types/DeleteTicketResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/tickets/types/Ticket.ts b/src/api/resources/tickets/types/Ticket.ts deleted file mode 100644 index 5e686d50..00000000 --- a/src/api/resources/tickets/types/Ticket.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.TicketCustomAttributes; - ticket_state?: Intercom.TicketState; - ticket_type?: Intercom.TicketType; - contacts: Intercom.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.LinkedObjectList; - ticket_parts?: Intercom.TicketParts; - /** Whether or not the ticket is shared with the customer. */ - is_shared?: boolean; -} - -export namespace Ticket { - /** Category of the Ticket. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/tickets/types/TicketContacts.ts b/src/api/resources/tickets/types/TicketContacts.ts deleted file mode 100644 index 1d775525..00000000 --- a/src/api/resources/tickets/types/TicketContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.ContactReference[]; -} diff --git a/src/api/resources/tickets/types/TicketPart.ts b/src/api/resources/tickets/types/TicketPart.ts deleted file mode 100644 index ffe19d95..00000000 --- a/src/api/resources/tickets/types/TicketPart.ts +++ /dev/null @@ -1,109 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.Reference; - author?: Intercom.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.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 const PreviousTicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; - /** The state of the ticket. */ - export const TicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type TicketState = (typeof TicketState)[keyof typeof TicketState]; - - /** - * 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/tickets/types/TicketState.ts b/src/api/resources/tickets/types/TicketState.ts deleted file mode 100644 index beef89c7..00000000 --- a/src/api/resources/tickets/types/TicketState.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/tickets/types/TicketStateDetailed.ts b/src/api/resources/tickets/types/TicketStateDetailed.ts deleted file mode 100644 index df97b118..00000000 --- a/src/api/resources/tickets/types/TicketStateDetailed.ts +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * 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.TicketType | undefined)[]; - } -} diff --git a/src/api/resources/tickets/types/TicketType.ts b/src/api/resources/tickets/types/TicketType.ts deleted file mode 100644 index 5ad0cd5d..00000000 --- a/src/api/resources/tickets/types/TicketType.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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.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 const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * 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.TicketState | undefined)[]; - } -} diff --git a/src/api/resources/tickets/types/TicketsReplyRequestBody.ts b/src/api/resources/tickets/types/TicketsReplyRequestBody.ts deleted file mode 100644 index f56d4a42..00000000 --- a/src/api/resources/tickets/types/TicketsReplyRequestBody.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type TicketsReplyRequestBody = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; diff --git a/src/api/resources/tickets/types/index.ts b/src/api/resources/tickets/types/index.ts deleted file mode 100644 index 0802fc77..00000000 --- a/src/api/resources/tickets/types/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./DeleteTicketResponse.js"; -export * from "./Ticket.js"; -export * from "./TicketContacts.js"; -export * from "./TicketPart.js"; -export * from "./TicketState.js"; -export * from "./TicketStateDetailed.js"; -export * from "./TicketsReplyRequestBody.js"; -export * from "./TicketType.js"; diff --git a/src/api/resources/unstable/client/Client.ts b/src/api/resources/unstable/client/Client.ts deleted file mode 100644 index f42b2732..00000000 --- a/src/api/resources/unstable/client/Client.ts +++ /dev/null @@ -1,220 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { AdminsClient } from "../resources/admins/client/Client.js"; -import { AiContentClient } from "../resources/aiContent/client/Client.js"; -import { ArticlesClient } from "../resources/articles/client/Client.js"; -import { AwayStatusReasonsClient } from "../resources/awayStatusReasons/client/Client.js"; -import { BrandsClient } from "../resources/brands/client/Client.js"; -import { CallsClient } from "../resources/calls/client/Client.js"; -import { CompaniesClient } from "../resources/companies/client/Client.js"; -import { ContactsClient } from "../resources/contacts/client/Client.js"; -import { ConversationsClient } from "../resources/conversations/client/Client.js"; -import { CustomChannelEventsClient } from "../resources/customChannelEvents/client/Client.js"; -import { CustomObjectInstancesClient } from "../resources/customObjectInstances/client/Client.js"; -import { DataAttributesClient } from "../resources/dataAttributes/client/Client.js"; -import { DataEventsClient } from "../resources/dataEvents/client/Client.js"; -import { DataExportClient } from "../resources/dataExport/client/Client.js"; -import { EmailsClient } from "../resources/emails/client/Client.js"; -import { ExportClient } from "../resources/export/client/Client.js"; -import { HelpCenterClient } from "../resources/helpCenter/client/Client.js"; -import { InternalArticlesClient } from "../resources/internalArticles/client/Client.js"; -import { JobsClient } from "../resources/jobs/client/Client.js"; -import { MacrosClient } from "../resources/macros/client/Client.js"; -import { MessagesClient } from "../resources/messages/client/Client.js"; -import { NewsClient } from "../resources/news/client/Client.js"; -import { NotesClient } from "../resources/notes/client/Client.js"; -import { SegmentsClient } from "../resources/segments/client/Client.js"; -import { SubscriptionTypesClient } from "../resources/subscriptionTypes/client/Client.js"; -import { SwitchClient } from "../resources/switch/client/Client.js"; -import { TagsClient } from "../resources/tags/client/Client.js"; -import { TeamsClient } from "../resources/teams/client/Client.js"; -import { TicketStatesClient } from "../resources/ticketStates/client/Client.js"; -import { TicketsClient } from "../resources/tickets/client/Client.js"; -import { TicketTypeAttributesClient } from "../resources/ticketTypeAttributes/client/Client.js"; -import { TicketTypesClient } from "../resources/ticketTypes/client/Client.js"; -import { VisitorsClient } from "../resources/visitors/client/Client.js"; -import { WorkflowsClient } from "../resources/workflows/client/Client.js"; - -export declare namespace UnstableClient { - export interface Options extends BaseClientOptions {} -} - -export class UnstableClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - protected _admins: AdminsClient | undefined; - protected _aiContent: AiContentClient | undefined; - protected _articles: ArticlesClient | undefined; - protected _awayStatusReasons: AwayStatusReasonsClient | undefined; - protected _export: ExportClient | undefined; - protected _helpCenter: HelpCenterClient | undefined; - protected _internalArticles: InternalArticlesClient | undefined; - protected _companies: CompaniesClient | undefined; - protected _notes: NotesClient | undefined; - protected _contacts: ContactsClient | undefined; - protected _subscriptionTypes: SubscriptionTypesClient | undefined; - protected _tags: TagsClient | undefined; - protected _conversations: ConversationsClient | undefined; - protected _customChannelEvents: CustomChannelEventsClient | undefined; - protected _customObjectInstances: CustomObjectInstancesClient | undefined; - protected _dataAttributes: DataAttributesClient | undefined; - protected _dataEvents: DataEventsClient | undefined; - protected _dataExport: DataExportClient | undefined; - protected _workflows: WorkflowsClient | undefined; - protected _jobs: JobsClient | undefined; - protected _macros: MacrosClient | undefined; - protected _messages: MessagesClient | undefined; - protected _news: NewsClient | undefined; - protected _segments: SegmentsClient | undefined; - protected _switch: SwitchClient | undefined; - protected _calls: CallsClient | undefined; - protected _teams: TeamsClient | undefined; - protected _ticketStates: TicketStatesClient | undefined; - protected _ticketTypeAttributes: TicketTypeAttributesClient | undefined; - protected _ticketTypes: TicketTypesClient | undefined; - protected _tickets: TicketsClient | undefined; - protected _visitors: VisitorsClient | undefined; - protected _brands: BrandsClient | undefined; - protected _emails: EmailsClient | undefined; - - constructor(options: UnstableClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - public get admins(): AdminsClient { - return (this._admins ??= new AdminsClient(this._options)); - } - - public get aiContent(): AiContentClient { - return (this._aiContent ??= new AiContentClient(this._options)); - } - - public get articles(): ArticlesClient { - return (this._articles ??= new ArticlesClient(this._options)); - } - - public get awayStatusReasons(): AwayStatusReasonsClient { - return (this._awayStatusReasons ??= new AwayStatusReasonsClient(this._options)); - } - - public get export(): ExportClient { - return (this._export ??= new ExportClient(this._options)); - } - - public get helpCenter(): HelpCenterClient { - return (this._helpCenter ??= new HelpCenterClient(this._options)); - } - - public get internalArticles(): InternalArticlesClient { - return (this._internalArticles ??= new InternalArticlesClient(this._options)); - } - - public get companies(): CompaniesClient { - return (this._companies ??= new CompaniesClient(this._options)); - } - - public get notes(): NotesClient { - return (this._notes ??= new NotesClient(this._options)); - } - - public get contacts(): ContactsClient { - return (this._contacts ??= new ContactsClient(this._options)); - } - - public get subscriptionTypes(): SubscriptionTypesClient { - return (this._subscriptionTypes ??= new SubscriptionTypesClient(this._options)); - } - - public get tags(): TagsClient { - return (this._tags ??= new TagsClient(this._options)); - } - - public get conversations(): ConversationsClient { - return (this._conversations ??= new ConversationsClient(this._options)); - } - - public get customChannelEvents(): CustomChannelEventsClient { - return (this._customChannelEvents ??= new CustomChannelEventsClient(this._options)); - } - - public get customObjectInstances(): CustomObjectInstancesClient { - return (this._customObjectInstances ??= new CustomObjectInstancesClient(this._options)); - } - - public get dataAttributes(): DataAttributesClient { - return (this._dataAttributes ??= new DataAttributesClient(this._options)); - } - - public get dataEvents(): DataEventsClient { - return (this._dataEvents ??= new DataEventsClient(this._options)); - } - - public get dataExport(): DataExportClient { - return (this._dataExport ??= new DataExportClient(this._options)); - } - - public get workflows(): WorkflowsClient { - return (this._workflows ??= new WorkflowsClient(this._options)); - } - - public get jobs(): JobsClient { - return (this._jobs ??= new JobsClient(this._options)); - } - - public get macros(): MacrosClient { - return (this._macros ??= new MacrosClient(this._options)); - } - - public get messages(): MessagesClient { - return (this._messages ??= new MessagesClient(this._options)); - } - - public get news(): NewsClient { - return (this._news ??= new NewsClient(this._options)); - } - - public get segments(): SegmentsClient { - return (this._segments ??= new SegmentsClient(this._options)); - } - - public get switch(): SwitchClient { - return (this._switch ??= new SwitchClient(this._options)); - } - - public get calls(): CallsClient { - return (this._calls ??= new CallsClient(this._options)); - } - - public get teams(): TeamsClient { - return (this._teams ??= new TeamsClient(this._options)); - } - - public get ticketStates(): TicketStatesClient { - return (this._ticketStates ??= new TicketStatesClient(this._options)); - } - - public get ticketTypeAttributes(): TicketTypeAttributesClient { - return (this._ticketTypeAttributes ??= new TicketTypeAttributesClient(this._options)); - } - - public get ticketTypes(): TicketTypesClient { - return (this._ticketTypes ??= new TicketTypesClient(this._options)); - } - - public get tickets(): TicketsClient { - return (this._tickets ??= new TicketsClient(this._options)); - } - - public get visitors(): VisitorsClient { - return (this._visitors ??= new VisitorsClient(this._options)); - } - - public get brands(): BrandsClient { - return (this._brands ??= new BrandsClient(this._options)); - } - - public get emails(): EmailsClient { - return (this._emails ??= new EmailsClient(this._options)); - } -} diff --git a/src/api/resources/unstable/client/index.ts b/src/api/resources/unstable/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/unstable/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/unstable/errors/BadRequestError.ts b/src/api/resources/unstable/errors/BadRequestError.ts deleted file mode 100644 index 351933dd..00000000 --- a/src/api/resources/unstable/errors/BadRequestError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; - -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/ConflictError.ts b/src/api/resources/unstable/errors/ConflictError.ts deleted file mode 100644 index afd826b8..00000000 --- a/src/api/resources/unstable/errors/ConflictError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; -import type * as Intercom from "../../../index.js"; - -export class ConflictError extends errors.IntercomError { - constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { - super({ - message: "ConflictError", - statusCode: 409, - body: body, - rawResponse: rawResponse, - }); - Object.setPrototypeOf(this, ConflictError.prototype); - } -} diff --git a/src/api/resources/unstable/errors/ForbiddenError.ts b/src/api/resources/unstable/errors/ForbiddenError.ts deleted file mode 100644 index a5eefa5f..00000000 --- a/src/api/resources/unstable/errors/ForbiddenError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 05de1b39..00000000 --- a/src/api/resources/unstable/errors/InternalServerError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 2b6a1c39..00000000 --- a/src/api/resources/unstable/errors/NotFoundError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; - -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 deleted file mode 100644 index 8213e523..00000000 --- a/src/api/resources/unstable/errors/TooManyRequestsError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 15ea9d4f..00000000 --- a/src/api/resources/unstable/errors/UnauthorizedError.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index a2021d64..00000000 --- a/src/api/resources/unstable/errors/UnprocessableEntityError.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../../../../core/index.js"; -import * as errors from "../../../../errors/index.js"; - -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 deleted file mode 100644 index 200c43d1..00000000 --- a/src/api/resources/unstable/errors/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./BadRequestError.js"; -export * from "./ConflictError.js"; -export * from "./ForbiddenError.js"; -export * from "./InternalServerError.js"; -export * from "./NotFoundError.js"; -export * from "./TooManyRequestsError.js"; -export * from "./UnauthorizedError.js"; -export * from "./UnprocessableEntityError.js"; diff --git a/src/api/resources/unstable/index.ts b/src/api/resources/unstable/index.ts deleted file mode 100644 index d73889d8..00000000 --- a/src/api/resources/unstable/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./client/index.js"; -export * from "./errors/index.js"; -export * from "./resources/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/admins/client/Client.ts b/src/api/resources/unstable/resources/admins/client/Client.ts deleted file mode 100644 index ece2566e..00000000 --- a/src/api/resources/unstable/resources/admins/client/Client.ts +++ /dev/null @@ -1,397 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace AdminsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Admins - */ -export class AdminsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AdminsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.admins.identifyAdmin() - */ - public identifyAdmin( - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__identifyAdmin(requestOptions)); - } - - private async __identifyAdmin( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "me", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/me"); - } - - /** - * You can set an Admin as away for the Inbox. - * - * @param {Intercom.unstable.SetAwayAdminRequest} request - * @param {AdminsClient.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?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__setAwayAdmin(request, requestOptions)); - } - - private async __setAwayAdmin( - request: Intercom.unstable.SetAwayAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(id)}/away`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/admins/{id}/away"); - } - - /** - * You can get a log of activities by all admins in an app. - * - * @param {Intercom.unstable.ListActivityLogsRequest} request - * @param {AdminsClient.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?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listActivityLogs(request, requestOptions)); - } - - private async __listActivityLogs( - request: Intercom.unstable.ListActivityLogsRequest, - requestOptions?: AdminsClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "admins/activity_logs", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/activity_logs"); - } - - /** - * You can fetch a list of admins for a given workspace. - * - * @param {AdminsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.admins.listAdmins() - */ - public listAdmins( - requestOptions?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAdmins(requestOptions)); - } - - private async __listAdmins( - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "admins", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins"); - } - - /** - * You can retrieve the details of a single admin. - * - * @param {Intercom.unstable.RetrieveAdminRequest} request - * @param {AdminsClient.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?: AdminsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveAdmin(request, requestOptions)); - } - - private async __retrieveAdmin( - request: Intercom.unstable.RetrieveAdminRequest, - requestOptions?: AdminsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `admins/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/admins/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/admins/client/index.ts b/src/api/resources/unstable/resources/admins/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/admins/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts b/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts deleted file mode 100644 index f5608b49..00000000 --- a/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index a7ae3952..00000000 --- a/src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 7c270dec..00000000 --- a/src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts +++ /dev/null @@ -1,35 +0,0 @@ -// 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 deleted file mode 100644 index 48a61029..00000000 --- a/src/api/resources/unstable/resources/admins/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { ListActivityLogsRequest } from "./ListActivityLogsRequest.js"; -export type { RetrieveAdminRequest } from "./RetrieveAdminRequest.js"; -export type { SetAwayAdminRequest } from "./SetAwayAdminRequest.js"; diff --git a/src/api/resources/unstable/resources/admins/index.ts b/src/api/resources/unstable/resources/admins/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/admins/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/admins/types/Admin.ts b/src/api/resources/unstable/resources/admins/types/Admin.ts deleted file mode 100644 index 113cc504..00000000 --- a/src/api/resources/unstable/resources/admins/types/Admin.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 838f94f4..00000000 --- a/src/api/resources/unstable/resources/admins/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Admin.js"; diff --git a/src/api/resources/unstable/resources/aiAgent/index.ts b/src/api/resources/unstable/resources/aiAgent/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/unstable/resources/aiAgent/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts b/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts deleted file mode 100644 index 868b1cd9..00000000 --- a/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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?: AiAgent.LastAnswerType; - /** The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ - resolution_state?: AiAgent.ResolutionState; - /** 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; - /** The time when the AI agent rating was created. */ - created_at?: number; - /** The time when the AI agent rating was last updated. */ - updated_at?: number; - content_sources?: Intercom.unstable.ContentSourcesList; -} - -export namespace AiAgent { - /** The type of the source that triggered AI Agent involvement in the conversation. */ - export const SourceType = { - EssentialsPlanSetup: "essentials_plan_setup", - Profile: "profile", - Workflow: "workflow", - WorkflowPreview: "workflow_preview", - FinPreview: "fin_preview", - } as const; - export type SourceType = (typeof SourceType)[keyof typeof SourceType]; - /** The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` */ - export const LastAnswerType = { - AiAnswer: "ai_answer", - CustomAnswer: "custom_answer", - } as const; - export type LastAnswerType = (typeof LastAnswerType)[keyof typeof LastAnswerType]; - /** The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ - export const ResolutionState = { - AssumedResolution: "assumed_resolution", - ConfirmedResolution: "confirmed_resolution", - Escalated: "escalated", - NegativeFeedback: "negative_feedback", - ProcedureHandoff: "procedure_handoff", - } as const; - export type ResolutionState = (typeof ResolutionState)[keyof typeof ResolutionState]; -} diff --git a/src/api/resources/unstable/resources/aiAgent/types/index.ts b/src/api/resources/unstable/resources/aiAgent/types/index.ts deleted file mode 100644 index 27ef772f..00000000 --- a/src/api/resources/unstable/resources/aiAgent/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./AiAgent.js"; diff --git a/src/api/resources/unstable/resources/aiContent/client/Client.ts b/src/api/resources/unstable/resources/aiContent/client/Client.ts deleted file mode 100644 index cdb6bcae..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/Client.ts +++ /dev/null @@ -1,783 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace AiContentClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * 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 AiContentClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AiContentClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can retrieve a list of all content import sources for a workspace. - * - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.aiContent.listContentImportSources() - */ - public listContentImportSources( - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listContentImportSources(requestOptions)); - } - - private async __listContentImportSources( - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/content_import_sources", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/content_import_sources"); - } - - /** - * You can create a new content import source by sending a POST request to this endpoint. - * - * @param {Intercom.unstable.CreateContentImportSourceRequest} request - * @param {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createContentImportSource(request, requestOptions)); - } - - private async __createContentImportSource( - request: Intercom.unstable.CreateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/content_import_sources", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ...request, sync_behavior: "api" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ai/content_import_sources"); - } - - /** - * @param {Intercom.unstable.GetContentImportSourceRequest} request - * @param {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getContentImportSource(request, requestOptions)); - } - - private async __getContentImportSource( - request: Intercom.unstable.GetContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/ai/content_import_sources/{id}", - ); - } - - /** - * You can update an existing content import source. - * - * @param {Intercom.unstable.UpdateContentImportSourceRequest} request - * @param {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateContentImportSource(request, requestOptions)); - } - - private async __updateContentImportSource( - request: Intercom.unstable.UpdateContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/ai/content_import_sources/{id}", - ); - } - - /** - * 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 {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteContentImportSource(request, requestOptions)); - } - - private async __deleteContentImportSource( - request: Intercom.unstable.DeleteContentImportSourceRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/content_import_sources/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/ai/content_import_sources/{id}", - ); - } - - /** - * You can retrieve a list of all external pages for a workspace. - * - * @param {AiContentClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.aiContent.listExternalPages() - */ - public listExternalPages( - requestOptions?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listExternalPages(requestOptions)); - } - - private async __listExternalPages( - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/external_pages", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/external_pages"); - } - - /** - * 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 {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createExternalPage(request, requestOptions)); - } - - private async __createExternalPage( - request: Intercom.unstable.CreateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ai/external_pages", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ...request, locale: "en" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ai/external_pages"); - } - - /** - * You can retrieve an external page. - * - * @param {Intercom.unstable.GetExternalPageRequest} request - * @param {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getExternalPage(request, requestOptions)); - } - - private async __getExternalPage( - request: Intercom.unstable.GetExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ai/external_pages/{id}"); - } - - /** - * You can update an existing external page (if it was created via the API). - * - * @param {Intercom.unstable.UpdateExternalPageRequest} request - * @param {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateExternalPage(request, requestOptions)); - } - - private async __updateExternalPage( - request: Intercom.unstable.UpdateExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: { ..._body, locale: "en" }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/ai/external_pages/{id}"); - } - - /** - * 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 {AiContentClient.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?: AiContentClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteExternalPage(request, requestOptions)); - } - - private async __deleteExternalPage( - request: Intercom.unstable.DeleteExternalPageRequest, - requestOptions?: AiContentClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ai/external_pages/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/ai/external_pages/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/aiContent/client/index.ts b/src/api/resources/unstable/resources/aiContent/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts deleted file mode 100644 index f487b162..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts deleted file mode 100644 index c4f5e914..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 255ebcd0..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 87532df3..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 199749ac..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index c7d50ef1..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 48401914..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts +++ /dev/null @@ -1,36 +0,0 @@ -// 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 const SyncBehavior = { - Api: "api", - Automated: "automated", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts deleted file mode 100644 index ccfddc5e..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 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 deleted file mode 100644 index 2c010829..00000000 --- a/src/api/resources/unstable/resources/aiContent/client/requests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type { CreateContentImportSourceRequest } from "./CreateContentImportSourceRequest.js"; -export type { CreateExternalPageRequest } from "./CreateExternalPageRequest.js"; -export type { DeleteContentImportSourceRequest } from "./DeleteContentImportSourceRequest.js"; -export type { DeleteExternalPageRequest } from "./DeleteExternalPageRequest.js"; -export type { GetContentImportSourceRequest } from "./GetContentImportSourceRequest.js"; -export type { GetExternalPageRequest } from "./GetExternalPageRequest.js"; -export type { UpdateContentImportSourceRequest } from "./UpdateContentImportSourceRequest.js"; -export type { UpdateExternalPageRequest } from "./UpdateExternalPageRequest.js"; diff --git a/src/api/resources/unstable/resources/aiContent/index.ts b/src/api/resources/unstable/resources/aiContent/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/aiContent/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts deleted file mode 100644 index e65d8d1a..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts +++ /dev/null @@ -1,39 +0,0 @@ -// 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 const SyncBehavior = { - Api: "api", - Automatic: "automatic", - Manual: "manual", - } as const; - export type SyncBehavior = (typeof SyncBehavior)[keyof typeof SyncBehavior]; - /** The status of the content import source. */ - export const Status = { - Active: "active", - Deactivated: "deactivated", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts deleted file mode 100644 index ca3dfb3a..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 97afb31c..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts +++ /dev/null @@ -1,35 +0,0 @@ -// 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 deleted file mode 100644 index 94172e4f..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 4a084844..00000000 --- a/src/api/resources/unstable/resources/aiContent/types/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./ContentImportSource.js"; -export * from "./ContentImportSourcesList.js"; -export * from "./ExternalPage.js"; -export * from "./ExternalPagesList.js"; diff --git a/src/api/resources/unstable/resources/aiContentSource/index.ts b/src/api/resources/unstable/resources/aiContentSource/index.ts deleted file mode 100644 index 2f88e301..00000000 --- a/src/api/resources/unstable/resources/aiContentSource/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts b/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts deleted file mode 100644 index 9b504015..00000000 --- a/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 const ContentType = { - File: "file", - Article: "article", - ExternalContent: "external_content", - ContentSnippet: "content_snippet", - WorkflowConnectorAction: "workflow_connector_action", - } as const; - export type ContentType = (typeof ContentType)[keyof typeof ContentType]; -} diff --git a/src/api/resources/unstable/resources/aiContentSource/types/index.ts b/src/api/resources/unstable/resources/aiContentSource/types/index.ts deleted file mode 100644 index 190780ca..00000000 --- a/src/api/resources/unstable/resources/aiContentSource/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ContentSource.js"; diff --git a/src/api/resources/unstable/resources/articles/client/Client.ts b/src/api/resources/unstable/resources/articles/client/Client.ts deleted file mode 100644 index 5ab11f3e..00000000 --- a/src/api/resources/unstable/resources/articles/client/Client.ts +++ /dev/null @@ -1,417 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ArticlesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Articles - */ -export class ArticlesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ArticlesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.articles.listArticles() - */ - public listArticles( - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listArticles(requestOptions)); - } - - private async __listArticles( - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles"); - } - - /** - * You can create a new article by making a POST request to `https://api.intercom.io/articles`. - * - * @param {unknown} request - * @param {ArticlesClient.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?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createArticle(request, requestOptions)); - } - - private async __createArticle( - request?: unknown, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/articles"); - } - - /** - * 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 {ArticlesClient.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?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveArticle(request, requestOptions)); - } - - private async __retrieveArticle( - request: Intercom.unstable.RetrieveArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/{id}"); - } - - /** - * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. - * - * @param {Intercom.unstable.DeleteArticleRequest} request - * @param {ArticlesClient.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?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteArticle(request, requestOptions)); - } - - private async __deleteArticle( - request: Intercom.unstable.DeleteArticleRequest, - requestOptions?: ArticlesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `articles/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/articles/{id}"); - } - - /** - * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. - * - * @param {Intercom.unstable.SearchArticlesRequest} request - * @param {ArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.articles.searchArticles({ - * phrase: "Getting started", - * state: "published", - * help_center_id: 1, - * highlight: true - * }) - */ - public searchArticles( - request: Intercom.unstable.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchArticles(request, requestOptions)); - } - - private async __searchArticles( - request: Intercom.unstable.SearchArticlesRequest = {}, - requestOptions?: ArticlesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles/search", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/articles/search"); - } -} diff --git a/src/api/resources/unstable/resources/articles/client/index.ts b/src/api/resources/unstable/resources/articles/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/articles/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts b/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts deleted file mode 100644 index 3429b3ea..00000000 --- a/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index b1b95775..00000000 --- a/src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 3416dd98..00000000 --- a/src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * phrase: "Getting started", - * state: "published", - * help_center_id: 1, - * highlight: true - * } - */ -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 deleted file mode 100644 index e0a15786..00000000 --- a/src/api/resources/unstable/resources/articles/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { DeleteArticleRequest } from "./DeleteArticleRequest.js"; -export type { RetrieveArticleRequest } from "./RetrieveArticleRequest.js"; -export type { SearchArticlesRequest } from "./SearchArticlesRequest.js"; diff --git a/src/api/resources/unstable/resources/articles/index.ts b/src/api/resources/unstable/resources/articles/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/articles/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/articles/types/Article.ts b/src/api/resources/unstable/resources/articles/types/Article.ts deleted file mode 100644 index cab08a5d..00000000 --- a/src/api/resources/unstable/resources/articles/types/Article.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 9c33e430..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts +++ /dev/null @@ -1,49 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts deleted file mode 100644 index c80f22fa..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts +++ /dev/null @@ -1,61 +0,0 @@ -// 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 const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - 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 const Type = { - Highlight: "highlight", - Plain: "plain", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts deleted file mode 100644 index 71b72609..00000000 --- a/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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/InternalArticle.ts b/src/api/resources/unstable/resources/articles/types/InternalArticle.ts deleted file mode 100644 index 9cea2830..00000000 --- a/src/api/resources/unstable/resources/articles/types/InternalArticle.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The Internal Articles API is a central place to gather all information and take actions on your internal articles. - */ -export type InternalArticle = Intercom.unstable.InternalArticleListItem; diff --git a/src/api/resources/unstable/resources/articles/types/index.ts b/src/api/resources/unstable/resources/articles/types/index.ts deleted file mode 100644 index ac1a15f9..00000000 --- a/src/api/resources/unstable/resources/articles/types/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./Article.js"; -export * from "./ArticleListItem.js"; -export * from "./ArticleSearchHighlights.js"; -export * from "./ArticleSearchResponse.js"; -export * from "./InternalArticle.js"; diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts b/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts deleted file mode 100644 index 5be942d3..00000000 --- a/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace AwayStatusReasonsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Away Status Reasons - */ -export class AwayStatusReasonsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: AwayStatusReasonsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Returns a list of all away status reasons configured for the workspace, including deleted ones. - * - * @param {AwayStatusReasonsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.awayStatusReasons.listAwayStatusReasons() - */ - public listAwayStatusReasons( - requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions)); - } - - private async __listAwayStatusReasons( - requestOptions?: AwayStatusReasonsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "away_status_reasons", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/away_status_reasons"); - } -} diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts b/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/unstable/resources/awayStatusReasons/index.ts b/src/api/resources/unstable/resources/awayStatusReasons/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/awayStatusReasons/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/brands/client/Client.ts b/src/api/resources/unstable/resources/brands/client/Client.ts deleted file mode 100644 index 29540dc4..00000000 --- a/src/api/resources/unstable/resources/brands/client/Client.ts +++ /dev/null @@ -1,167 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace BrandsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Brands - */ -export class BrandsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: BrandsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieves all brands for the workspace, including the default brand. - * The default brand id always matches the workspace - * - * @param {BrandsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.brands.listBrands() - */ - public listBrands( - requestOptions?: BrandsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listBrands(requestOptions)); - } - - private async __listBrands( - requestOptions?: BrandsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "brands", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.BrandList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/brands"); - } - - /** - * Fetches a specific brand by its unique identifier - * - * @param {Intercom.unstable.RetrieveBrandRequest} request - * @param {BrandsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.brands.retrieveBrand({ - * id: "id" - * }) - */ - public retrieveBrand( - request: Intercom.unstable.RetrieveBrandRequest, - requestOptions?: BrandsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveBrand(request, requestOptions)); - } - - private async __retrieveBrand( - request: Intercom.unstable.RetrieveBrandRequest, - requestOptions?: BrandsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `brands/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.Brand, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/brands/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/brands/client/index.ts b/src/api/resources/unstable/resources/brands/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/brands/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/brands/client/requests/RetrieveBrandRequest.ts b/src/api/resources/unstable/resources/brands/client/requests/RetrieveBrandRequest.ts deleted file mode 100644 index fc52ec4e..00000000 --- a/src/api/resources/unstable/resources/brands/client/requests/RetrieveBrandRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface RetrieveBrandRequest { - /** The unique identifier of the brand */ - id: string; -} diff --git a/src/api/resources/unstable/resources/brands/client/requests/index.ts b/src/api/resources/unstable/resources/brands/client/requests/index.ts deleted file mode 100644 index 813c2ce1..00000000 --- a/src/api/resources/unstable/resources/brands/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { RetrieveBrandRequest } from "./RetrieveBrandRequest.js"; diff --git a/src/api/resources/unstable/resources/brands/index.ts b/src/api/resources/unstable/resources/brands/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/brands/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/brands/types/Brand.ts b/src/api/resources/unstable/resources/brands/types/Brand.ts deleted file mode 100644 index 53a416af..00000000 --- a/src/api/resources/unstable/resources/brands/types/Brand.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Represents a branding configuration for the workspace - */ -export interface Brand { - /** The type of object */ - type?: string; - /** Unique brand identifier. For default brand, matches the workspace ID */ - id?: string; - /** Display name of the brand */ - name?: string; - /** Whether this is the workspace's default brand */ - is_default?: boolean; - /** Unix timestamp of brand creation */ - created_at?: number; - /** Unix timestamp of last modification */ - updated_at?: number; - /** Associated help center identifier */ - help_center_id?: string; - /** Default email settings ID for this brand */ - default_address_settings_id?: string; -} diff --git a/src/api/resources/unstable/resources/brands/types/BrandList.ts b/src/api/resources/unstable/resources/brands/types/BrandList.ts deleted file mode 100644 index 3d7330de..00000000 --- a/src/api/resources/unstable/resources/brands/types/BrandList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A list of brands - */ -export interface BrandList { - /** The type of object */ - type?: string; - data?: Intercom.unstable.Brand[]; -} diff --git a/src/api/resources/unstable/resources/brands/types/index.ts b/src/api/resources/unstable/resources/brands/types/index.ts deleted file mode 100644 index c0d308e0..00000000 --- a/src/api/resources/unstable/resources/brands/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Brand.js"; -export * from "./BrandList.js"; diff --git a/src/api/resources/unstable/resources/calls/client/Client.ts b/src/api/resources/unstable/resources/calls/client/Client.ts deleted file mode 100644 index 24f1b6f6..00000000 --- a/src/api/resources/unstable/resources/calls/client/Client.ts +++ /dev/null @@ -1,710 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CallsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Calls - */ -export class CallsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CallsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve a paginated list of calls. - * - * @param {Intercom.unstable.ListCallsRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.calls.listCalls({ - * page: 1, - * per_page: 1 - * }) - */ - public listCalls( - request: Intercom.unstable.ListCallsRequest = {}, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCalls(request, requestOptions)); - } - - private async __listCalls( - request: Intercom.unstable.ListCallsRequest = {}, - requestOptions?: CallsClient.RequestOptions, - ): 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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "calls", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.CallList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls"); - } - - /** - * Retrieve a single call by id. - * - * @param {Intercom.unstable.ShowCallRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.showCall({ - * id: "id" - * }) - */ - public showCall( - request: Intercom.unstable.ShowCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCall(request, requestOptions)); - } - - private async __showCall( - request: Intercom.unstable.ShowCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.Call, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{id}"); - } - - /** - * Redirects to a signed URL for the call's recording if it exists. - * - * @param {Intercom.unstable.ShowCallRecordingRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.showCallRecording({ - * id: "id" - * }) - */ - public showCallRecording( - request: Intercom.unstable.ShowCallRecordingRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCallRecording(request, requestOptions)); - } - - private async __showCallRecording( - request: Intercom.unstable.ShowCallRecordingRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(id)}/recording`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - ); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{id}/recording"); - } - - /** - * Returns the transcript for the specified call as a downloadable text file. - * - * @param {Intercom.unstable.ShowCallTranscriptRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.showCallTranscript({ - * id: "id" - * }) - */ - public showCallTranscript( - request: Intercom.unstable.ShowCallTranscriptRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showCallTranscript(request, requestOptions)); - } - - private async __showCallTranscript( - request: Intercom.unstable.ShowCallTranscriptRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `calls/${core.url.encodePathParam(id)}/transcript`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - responseType: "text", - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as string, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/calls/{id}/transcript"); - } - - /** - * Retrieve calls by a list of conversation ids and include transcripts when available. - * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. - * - * @param {Intercom.unstable.ListCallsWithTranscriptsRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.calls.listCallsWithTranscripts({ - * conversation_ids: ["64619700005694", "64619700005695"] - * }) - */ - public listCallsWithTranscripts( - request: Intercom.unstable.ListCallsWithTranscriptsRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCallsWithTranscripts(request, requestOptions)); - } - - private async __listCallsWithTranscripts( - request: Intercom.unstable.ListCallsWithTranscriptsRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "calls/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.ListCallsWithTranscriptsResponse, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/calls/search"); - } - - /** - * Register a Fin Voice call with Intercom. This endpoint creates an external reference - * that links an external call identifier to an Intercom call and conversation. - * - * The call can be from different sources: - * - AWS Connect (default) - * - Five9 - * - Zoom Phone - * - * @param {Intercom.unstable.RegisterFinVoiceCallRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.ConflictError} - * - * @example - * await client.unstable.calls.registerFinVoiceCall({ - * phone_number: "+1234567890", - * call_id: "call-123-abc" - * }) - */ - public registerFinVoiceCall( - request?: Intercom.unstable.RegisterFinVoiceCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__registerFinVoiceCall(request, requestOptions)); - } - - private async __registerFinVoiceCall( - request?: Intercom.unstable.RegisterFinVoiceCallRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "fin_voice/register", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, 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 409: - throw new Intercom.unstable.ConflictError( - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/fin_voice/register"); - } - - /** - * Retrieve information about a Fin Voice call using the external reference ID. - * - * @param {Intercom.unstable.CollectFinVoiceCallByIdRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.collectFinVoiceCallById({ - * id: 1 - * }) - */ - public collectFinVoiceCallById( - request: Intercom.unstable.CollectFinVoiceCallByIdRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallById(request, requestOptions)); - } - - private async __collectFinVoiceCallById( - request: Intercom.unstable.CollectFinVoiceCallByIdRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `fin_voice/collect/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/fin_voice/collect/{id}"); - } - - /** - * Retrieve information about a Fin Voice call using the external call identifier. - * - * @param {Intercom.unstable.CollectFinVoiceCallByExternalIdRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.collectFinVoiceCallByExternalId({ - * external_id: "external_id" - * }) - */ - public collectFinVoiceCallByExternalId( - request: Intercom.unstable.CollectFinVoiceCallByExternalIdRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallByExternalId(request, requestOptions)); - } - - private async __collectFinVoiceCallByExternalId( - request: Intercom.unstable.CollectFinVoiceCallByExternalIdRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { external_id: externalId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `fin_voice/external_id/${core.url.encodePathParam(externalId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.AiCallResponse, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/fin_voice/external_id/{external_id}", - ); - } - - /** - * Retrieve information about a Fin Voice call using the phone number. - * - * Returns the most recent matched call for the given phone number, ordered by creation date. - * - * @param {Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest} request - * @param {CallsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - * phone_number: "phone_number" - * }) - */ - public collectFinVoiceCallByPhoneNumber( - request: Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest, - requestOptions?: CallsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__collectFinVoiceCallByPhoneNumber(request, requestOptions)); - } - - private async __collectFinVoiceCallByPhoneNumber( - request: Intercom.unstable.CollectFinVoiceCallByPhoneNumberRequest, - requestOptions?: CallsClient.RequestOptions, - ): Promise> { - const { phone_number: phoneNumber } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `fin_voice/phone_number/${core.url.encodePathParam(phoneNumber)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.Error_, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/fin_voice/phone_number/{phone_number}", - ); - } -} diff --git a/src/api/resources/unstable/resources/calls/client/index.ts b/src/api/resources/unstable/resources/calls/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/calls/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts deleted file mode 100644 index 1cdf7af4..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByExternalIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * external_id: "external_id" - * } - */ -export interface CollectFinVoiceCallByExternalIdRequest { - /** The external call identifier from the call provider */ - external_id: string; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts deleted file mode 100644 index f3587f16..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1 - * } - */ -export interface CollectFinVoiceCallByIdRequest { - /** The external reference ID */ - id: number; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts deleted file mode 100644 index 145f26e3..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/CollectFinVoiceCallByPhoneNumberRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * phone_number: "phone_number" - * } - */ -export interface CollectFinVoiceCallByPhoneNumberRequest { - /** Phone number in E.164 format */ - phone_number: string; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ListCallsRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/ListCallsRequest.ts deleted file mode 100644 index 74c29012..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/ListCallsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page: 1, - * per_page: 1 - * } - */ -export interface ListCallsRequest { - /** The page of results to fetch. Defaults to first page */ - page?: number; - /** How many results to display per page. Defaults to 25. Max 25. */ - per_page?: number; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts deleted file mode 100644 index 92d644c1..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/ListCallsWithTranscriptsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * conversation_ids: ["64619700005694", "64619700005695"] - * } - */ -export interface ListCallsWithTranscriptsRequest { - /** A list of conversation ids to fetch calls for. Maximum 20. */ - conversation_ids: string[]; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRecordingRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/ShowCallRecordingRequest.ts deleted file mode 100644 index e17a6c0f..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRecordingRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface ShowCallRecordingRequest { - /** The id of the call */ - id: string; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/ShowCallRequest.ts deleted file mode 100644 index ee5cddee..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/ShowCallRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface ShowCallRequest { - /** The id of the call to retrieve */ - id: string; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/ShowCallTranscriptRequest.ts b/src/api/resources/unstable/resources/calls/client/requests/ShowCallTranscriptRequest.ts deleted file mode 100644 index a21f329d..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/ShowCallTranscriptRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface ShowCallTranscriptRequest { - /** The id of the call */ - id: string; -} diff --git a/src/api/resources/unstable/resources/calls/client/requests/index.ts b/src/api/resources/unstable/resources/calls/client/requests/index.ts deleted file mode 100644 index d1c18782..00000000 --- a/src/api/resources/unstable/resources/calls/client/requests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type { CollectFinVoiceCallByExternalIdRequest } from "./CollectFinVoiceCallByExternalIdRequest.js"; -export type { CollectFinVoiceCallByIdRequest } from "./CollectFinVoiceCallByIdRequest.js"; -export type { CollectFinVoiceCallByPhoneNumberRequest } from "./CollectFinVoiceCallByPhoneNumberRequest.js"; -export type { ListCallsRequest } from "./ListCallsRequest.js"; -export type { ListCallsWithTranscriptsRequest } from "./ListCallsWithTranscriptsRequest.js"; -export type { ShowCallRecordingRequest } from "./ShowCallRecordingRequest.js"; -export type { ShowCallRequest } from "./ShowCallRequest.js"; -export type { ShowCallTranscriptRequest } from "./ShowCallTranscriptRequest.js"; diff --git a/src/api/resources/unstable/resources/calls/index.ts b/src/api/resources/unstable/resources/calls/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/calls/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/calls/types/Call.ts b/src/api/resources/unstable/resources/calls/types/Call.ts deleted file mode 100644 index 18bb1be3..00000000 --- a/src/api/resources/unstable/resources/calls/types/Call.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Represents a phone call in Intercom - */ -export interface Call { - /** String representing the object's type. Always has the value `call`. */ - type?: string; - /** The id of the call. */ - id?: string; - /** The id of the conversation associated with the call, if any. */ - conversation_id?: string; - /** The id of the admin associated with the call, if any. */ - admin_id?: string; - /** The id of the contact associated with the call, if any. */ - contact_id?: string; - /** The current state of the call. */ - state?: string; - initiated_at?: Intercom.unstable.Datetime; - answered_at?: Intercom.unstable.Datetime; - ended_at?: Intercom.unstable.Datetime; - created_at?: Intercom.unstable.Datetime; - updated_at?: Intercom.unstable.Datetime; - /** API URL to download or redirect to the call recording if available. */ - recording_url?: string; - /** API URL to the call transcript if available. */ - transcription_url?: string; - /** The type of call. */ - call_type?: string; - /** The direction of the call. */ - direction?: string; - /** The reason for the call end, if applicable. */ - ended_reason?: string; - /** The phone number involved in the call, in E.164 format. */ - phone?: string; - /** API URL to the AI Agent (Fin) call recording if available. */ - fin_recording_url?: string; - /** API URL to the AI Agent (Fin) call transcript if available. */ - fin_transcription_url?: string; -} diff --git a/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts b/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts deleted file mode 100644 index ec066741..00000000 --- a/src/api/resources/unstable/resources/calls/types/ListCallsWithTranscriptsResponse.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -export interface ListCallsWithTranscriptsResponse { - type?: string; - data?: ListCallsWithTranscriptsResponse.Data.Item[]; -} - -export namespace ListCallsWithTranscriptsResponse { - export type Data = Data.Item[]; - - export namespace Data { - export interface Item extends Intercom.unstable.Call { - /** The call transcript if available, otherwise an empty array. */ - transcript?: Record[]; - /** The status of the transcript if available. */ - transcript_status?: string; - } - } -} diff --git a/src/api/resources/unstable/resources/calls/types/index.ts b/src/api/resources/unstable/resources/calls/types/index.ts deleted file mode 100644 index a7b7c7f7..00000000 --- a/src/api/resources/unstable/resources/calls/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Call.js"; -export * from "./ListCallsWithTranscriptsResponse.js"; diff --git a/src/api/resources/unstable/resources/companies/client/Client.ts b/src/api/resources/unstable/resources/companies/client/Client.ts deleted file mode 100644 index 575c345d..00000000 --- a/src/api/resources/unstable/resources/companies/client/Client.ts +++ /dev/null @@ -1,968 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CompaniesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Companies - */ -export class CompaniesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CompaniesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {CompaniesClient.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", - * page: 1, - * per_page: 1 - * }) - */ - public retrieveCompany( - request: Intercom.unstable.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveCompany(request, requestOptions)); - } - - private async __retrieveCompany( - request: Intercom.unstable.RetrieveCompanyRequest = {}, - requestOptions?: CompaniesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies"); - } - - /** - * 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 {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createOrUpdateCompany(request, requestOptions)); - } - - private async __createOrUpdateCompany( - request?: unknown, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies"); - } - - /** - * You can fetch a single company. - * - * @param {Intercom.unstable.RetrieveACompanyByIdRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveACompanyById(request, requestOptions)); - } - - private async __retrieveACompanyById( - request: Intercom.unstable.RetrieveACompanyByIdRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}"); - } - - /** - * 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 {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateCompany(request, requestOptions)); - } - - private async __updateCompany( - request: Intercom.unstable.UpdateCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/companies/{id}"); - } - - /** - * You can delete a single company. - * - * @param {Intercom.unstable.DeleteCompanyRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCompany(request, requestOptions)); - } - - private async __deleteCompany( - request: Intercom.unstable.DeleteCompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/companies/{id}"); - } - - /** - * You can fetch a list of all contacts that belong to a company. - * - * @param {Intercom.unstable.ListAttachedContactsRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); - } - - private async __listAttachedContacts( - request: Intercom.unstable.ListAttachedContactsRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/contacts`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/contacts"); - } - - /** - * You can fetch a list of all segments that belong to a company. - * - * @param {Intercom.unstable.ListAttachedSegmentsForCompaniesRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAttachedSegmentsForCompanies(request, requestOptions)); - } - - private async __listAttachedSegmentsForCompanies( - request: Intercom.unstable.ListAttachedSegmentsForCompaniesRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/segments`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/segments"); - } - - /** - * 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 {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.companies.listAllCompanies({ - * page: 1, - * per_page: 1, - * order: "desc" - * }) - */ - public listAllCompanies( - request: Intercom.unstable.ListAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAllCompanies(request, requestOptions)); - } - - private async __listAllCompanies( - request: Intercom.unstable.ListAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/list", - ), - method: "POST", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/companies/list"); - } - - /** - * 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 {CompaniesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.companies.scrollOverAllCompanies({ - * scroll_param: "scroll_param" - * }) - */ - public scrollOverAllCompanies( - request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__scrollOverAllCompanies(request, requestOptions)); - } - - private async __scrollOverAllCompanies( - request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { scroll_param: scrollParam } = request; - const _queryParams: Record = {}; - if (scrollParam != null) { - _queryParams.scroll_param = scrollParam; - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/scroll", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/scroll"); - } - - /** - * You can attach a company to a single contact. - * - * @param {Intercom.unstable.AttachContactToACompanyRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContactToACompany(request, requestOptions)); - } - - private async __attachContactToACompany( - request: Intercom.unstable.AttachContactToACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/companies`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/companies"); - } - - /** - * You can detach a company from a single contact. - * - * @param {Intercom.unstable.DetachContactFromACompanyRequest} request - * @param {CompaniesClient.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?: CompaniesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContactFromACompany(request, requestOptions)); - } - - private async __detachContactFromACompany( - request: Intercom.unstable.DetachContactFromACompanyRequest, - requestOptions?: CompaniesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/companies/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/companies/{id}", - ); - } -} diff --git a/src/api/resources/unstable/resources/companies/client/index.ts b/src/api/resources/unstable/resources/companies/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/companies/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts deleted file mode 100644 index fbab4ca6..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index e1ad8abe..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index b80801fa..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 86b2ef07..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * page: 1, - * per_page: 1, - * 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 deleted file mode 100644 index e49c7dca..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 31d3c9d9..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index f53eaada..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index a3314297..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * name: "my company", - * company_id: "12345", - * tag_id: "678910", - * segment_id: "98765", - * page: 1, - * per_page: 1 - * } - */ -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 deleted file mode 100644 index 68f2ed8b..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * scroll_param: "scroll_param" - * } - */ -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 deleted file mode 100644 index b63f71c5..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 7bdff9f7..00000000 --- a/src/api/resources/unstable/resources/companies/client/requests/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type { AttachContactToACompanyRequest } from "./AttachContactToACompanyRequest.js"; -export type { DeleteCompanyRequest } from "./DeleteCompanyRequest.js"; -export type { DetachContactFromACompanyRequest } from "./DetachContactFromACompanyRequest.js"; -export type { ListAllCompaniesRequest } from "./ListAllCompaniesRequest.js"; -export type { ListAttachedContactsRequest } from "./ListAttachedContactsRequest.js"; -export type { ListAttachedSegmentsForCompaniesRequest } from "./ListAttachedSegmentsForCompaniesRequest.js"; -export type { RetrieveACompanyByIdRequest } from "./RetrieveACompanyByIdRequest.js"; -export type { RetrieveCompanyRequest } from "./RetrieveCompanyRequest.js"; -export type { ScrollOverAllCompaniesRequest } from "./ScrollOverAllCompaniesRequest.js"; -export type { UpdateCompanyRequest } from "./UpdateCompanyRequest.js"; diff --git a/src/api/resources/unstable/resources/companies/index.ts b/src/api/resources/unstable/resources/companies/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/companies/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/companies/types/Company.ts b/src/api/resources/unstable/resources/companies/types/Company.ts deleted file mode 100644 index d2569495..00000000 --- a/src/api/resources/unstable/resources/companies/types/Company.ts +++ /dev/null @@ -1,86 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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; - /** The list of notes associated with the company */ - notes?: Company.Notes; -} - -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[]; - } - - /** - * The list of notes associated with the company - */ - export interface Notes { - /** The type of the object */ - type?: "note.list"; - notes?: Intercom.unstable.CompanyNote[]; - } -} diff --git a/src/api/resources/unstable/resources/companies/types/index.ts b/src/api/resources/unstable/resources/companies/types/index.ts deleted file mode 100644 index 19a19f61..00000000 --- a/src/api/resources/unstable/resources/companies/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Company.js"; diff --git a/src/api/resources/unstable/resources/contacts/client/Client.ts b/src/api/resources/unstable/resources/contacts/client/Client.ts deleted file mode 100644 index 531e8b52..00000000 --- a/src/api/resources/unstable/resources/contacts/client/Client.ts +++ /dev/null @@ -1,1251 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ContactsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your contacts - */ -export class ContactsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ContactsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of companies that are associated to a contact. - * - * @param {Intercom.unstable.ListCompaniesForAContactRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCompaniesForAContact(request, requestOptions)); - } - - private async __listCompaniesForAContact( - request: Intercom.unstable.ListCompaniesForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/companies`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/companies"); - } - - /** - * You can fetch a list of segments that are associated to a contact. - * - * @param {Intercom.unstable.ListSegmentsForAContactRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSegmentsForAContact(request, requestOptions)); - } - - private async __listSegmentsForAContact( - request: Intercom.unstable.ListSegmentsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/segments`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/segments", - ); - } - - /** - * 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 {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSubscriptionsForAContact(request, requestOptions)); - } - - private async __listSubscriptionsForAContact( - request: Intercom.unstable.ListSubscriptionsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/{contact_id}/subscriptions", - ); - } - - /** - * You can fetch a list of all tags that are attached to a specific contact. - * - * @param {Intercom.unstable.ListTagsForAContactRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTagsForAContact(request, requestOptions)); - } - - private async __listTagsForAContact( - request: Intercom.unstable.ListTagsForAContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contact_id}/tags"); - } - - /** - * You can fetch the details of a single contact. - * - * @param {Intercom.unstable.ShowContactRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showContact(request, requestOptions)); - } - - private async __showContact( - request: Intercom.unstable.ShowContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}"); - } - - /** - * 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 {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateContact(request, requestOptions)); - } - - private async __updateContact( - request: Intercom.unstable.UpdateContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/contacts/{id}"); - } - - /** - * You can delete a single contact. - * - * @param {Intercom.unstable.DeleteContactRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteContact(request, requestOptions)); - } - - private async __deleteContact( - request: Intercom.unstable.DeleteContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{id}"); - } - - /** - * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. - * - * @param {Intercom.unstable.MergeContactsRequest} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__mergeContact(request, requestOptions)); - } - - private async __mergeContact( - request: Intercom.unstable.MergeContactsRequest = {}, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/merge", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/merge"); - } - - /** - * 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 {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchContacts(request, requestOptions)); - } - - private async __searchContacts( - request: Intercom.unstable.SearchRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/search"); - } - - /** - * 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 {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.contacts.listContacts() - */ - public listContacts( - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listContacts(requestOptions)); - } - - private async __listContacts( - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts"); - } - - /** - * You can create a new contact (ie. user or lead). - * - * @param {Intercom.CreateContactRequestTwo} request - * @param {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createContact(request, requestOptions)); - } - - private async __createContact( - request?: Intercom.CreateContactRequestTwo, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts"); - } - - /** - * 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 {ContactsClient.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?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions)); - } - - private async __showContactByExternalId( - request: Intercom.unstable.ShowContactByExternalIdRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { external_id: externalId } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/find_by_external_id/${core.url.encodePathParam(externalId)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/contacts/find_by_external_id/{external_id}", - ); - } - - /** - * You can archive a single contact. - * - * @param {Intercom.unstable.ArchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.archiveContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public archiveContact( - request: Intercom.unstable.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__archiveContact(request, requestOptions)); - } - - private async __archiveContact( - request: Intercom.unstable.ArchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/archive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/archive"); - } - - /** - * You can unarchive a single contact. - * - * @param {Intercom.unstable.UnarchiveContactRequest} request - * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.unarchiveContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public unarchiveContact( - request: Intercom.unstable.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__unarchiveContact(request, requestOptions)); - } - - private async __unarchiveContact( - request: Intercom.unstable.UnarchiveContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/unarchive`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/unarchive"); - } - - /** - * 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 {ContactsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.contacts.blockContact({ - * id: "63a07ddf05a32042dffac965" - * }) - */ - public blockContact( - request: Intercom.unstable.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions)); - } - - private async __blockContact( - request: Intercom.unstable.BlockContactRequest, - requestOptions?: ContactsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/block`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/block"); - } -} diff --git a/src/api/resources/unstable/resources/contacts/client/index.ts b/src/api/resources/unstable/resources/contacts/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/contacts/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts deleted file mode 100644 index 15dad8b9..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 75e78626..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 55b557be..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 1e96546f..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 2d363b13..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 6413b23e..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 719e4d06..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 520d7f83..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index d6f2b0d8..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 170a185f..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 28b61c31..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 3d671681..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts +++ /dev/null @@ -1,48 +0,0 @@ -// 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; - /** A preferred language setting for the contact, used by Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null. */ - language_override?: string; - /** 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 deleted file mode 100644 index faea767c..00000000 --- a/src/api/resources/unstable/resources/contacts/client/requests/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type { ArchiveContactRequest } from "./ArchiveContactRequest.js"; -export type { BlockContactRequest } from "./BlockContactRequest.js"; -export type { DeleteContactRequest } from "./DeleteContactRequest.js"; -export type { ListCompaniesForAContactRequest } from "./ListCompaniesForAContactRequest.js"; -export type { ListSegmentsForAContactRequest } from "./ListSegmentsForAContactRequest.js"; -export type { ListSubscriptionsForAContactRequest } from "./ListSubscriptionsForAContactRequest.js"; -export type { ListTagsForAContactRequest } from "./ListTagsForAContactRequest.js"; -export type { MergeContactsRequest } from "./MergeContactsRequest.js"; -export type { ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest.js"; -export type { ShowContactRequest } from "./ShowContactRequest.js"; -export type { UnarchiveContactRequest } from "./UnarchiveContactRequest.js"; -export type { UpdateContactRequest } from "./UpdateContactRequest.js"; diff --git a/src/api/resources/unstable/resources/contacts/index.ts b/src/api/resources/unstable/resources/contacts/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/contacts/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/contacts/types/Contact.ts b/src/api/resources/unstable/resources/contacts/types/Contact.ts deleted file mode 100644 index cb4e3927..00000000 --- a/src/api/resources/unstable/resources/contacts/types/Contact.ts +++ /dev/null @@ -1,104 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 Intercom as the language of Fin and the Messenger even if their browser has a different setting. Supports ISO 639-1 two-letter language codes. If an unsupported code is supplied, the field will be set to null. */ - 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 deleted file mode 100644 index e7bb8739..00000000 --- a/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index 6a253944..00000000 --- a/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index 2e8b3f12..00000000 --- a/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index e8ffabcc..00000000 --- a/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index c67687b2..00000000 --- a/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index bf8c1f71..00000000 --- a/src/api/resources/unstable/resources/contacts/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./Contact.js"; -export * from "./CreateContactResponse.js"; -export * from "./MergeContactResponse.js"; -export * from "./ShowContactByExternalIdResponse.js"; -export * from "./ShowContactResponse.js"; -export * from "./UpdateContactResponse.js"; diff --git a/src/api/resources/unstable/resources/conversations/client/Client.ts b/src/api/resources/unstable/resources/conversations/client/Client.ts deleted file mode 100644 index 1823bcca..00000000 --- a/src/api/resources/unstable/resources/conversations/client/Client.ts +++ /dev/null @@ -1,1412 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ConversationsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Conversations - */ -export class ConversationsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ConversationsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * - * @example - * await client.unstable.conversations.listConversations({ - * per_page: 1, - * starting_after: "starting_after" - * }) - */ - public listConversations( - request: Intercom.unstable.ListConversationsRequest = {}, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listConversations(request, requestOptions)); - } - - private async __listConversations( - request: Intercom.unstable.ListConversationsRequest = {}, - requestOptions?: ConversationsClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations"); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createConversation(request, requestOptions)); - } - - private async __createConversation( - request: Intercom.unstable.CreateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations"); - } - - /** - * - * 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 {ConversationsClient.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", - * include_translations: true - * }) - */ - public retrieveConversation( - request: Intercom.unstable.RetrieveConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveConversation(request, requestOptions)); - } - - private async __retrieveConversation( - request: Intercom.unstable.RetrieveConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, display_as: displayAs, include_translations: includeTranslations } = request; - const _queryParams: Record = {}; - if (displayAs != null) { - _queryParams.display_as = displayAs; - } - - if (includeTranslations != null) { - _queryParams.include_translations = includeTranslations.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/conversations/{id}"); - } - - /** - * - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateConversation(request, requestOptions)); - } - - private async __updateConversation( - request: Intercom.unstable.UpdateConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, display_as: displayAs, ..._body } = request; - const _queryParams: Record = {}; - if (displayAs != null) { - _queryParams.display_as = displayAs; - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/conversations/{id}"); - } - - /** - * You can delete a single conversation. - * - * @param {Intercom.unstable.DeleteConversationRequest} request - * @param {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteConversation(request, requestOptions)); - } - - private async __deleteConversation( - request: Intercom.unstable.DeleteConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/conversations/{id}"); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchConversations(request, requestOptions)); - } - - private async __searchConversations( - request: Intercom.unstable.SearchRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/search"); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__replyConversation(request, requestOptions)); - } - - private async __replyConversation( - request: Intercom.unstable.ReplyConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/reply`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/reply"); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__manageConversation(request, requestOptions)); - } - - private async __manageConversation( - request: Intercom.unstable.ManageConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/parts`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/parts"); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachContactToConversation(request, requestOptions)); - } - - private async __attachContactToConversation( - request: Intercom.unstable.AttachContactToConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/customers`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{id}/customers", - ); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachContactFromConversation(request, requestOptions)); - } - - private async __detachContactFromConversation( - request: Intercom.unstable.DetachContactFromConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/customers/${core.url.encodePathParam(contactId)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}/customers/{contact_id}", - ); - } - - /** - * List all pause/resume events for a conversation. These events track when teammates paused or resumed handling a conversation. - * - * Requires the `read_conversations` OAuth scope. - * - * @param {Intercom.unstable.ListHandlingEventsRequest} request - * @param {ConversationsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.conversations.listHandlingEvents({ - * id: "123" - * }) - */ - public listHandlingEvents( - request: Intercom.unstable.ListHandlingEventsRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listHandlingEvents(request, requestOptions)); - } - - private async __listHandlingEvents( - request: Intercom.unstable.ListHandlingEventsRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/handling_events`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.HandlingEventList, 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/conversations/{id}/handling_events", - ); - } - - /** - * 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 {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__redactConversation(request, requestOptions)); - } - - private async __redactConversation( - request: Intercom.unstable.RedactConversationRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations/redact", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/redact"); - } - - /** - * You can convert a conversation to a ticket. - * - * @param {Intercom.unstable.ConvertConversationToTicketRequest} request - * @param {ConversationsClient.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?: ConversationsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__convertConversationToTicket(request, requestOptions)); - } - - private async __convertConversationToTicket( - request: Intercom.unstable.ConvertConversationToTicketRequest, - requestOptions?: ConversationsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(id)}/convert`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/conversations/{id}/convert"); - } -} diff --git a/src/api/resources/unstable/resources/conversations/client/index.ts b/src/api/resources/unstable/resources/conversations/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/conversations/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts deleted file mode 100644 index e7d06d91..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 5985d835..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 0f8bcd9a..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts +++ /dev/null @@ -1,47 +0,0 @@ -// 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 const Type = { - Lead: "lead", - User: "user", - Contact: "contact", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } -} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts deleted file mode 100644 index 1a07b952..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 415bfae9..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// 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 deleted file mode 100644 index 4908f563..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * per_page: 1, - * starting_after: "starting_after" - * } - */ -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/ListHandlingEventsRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ListHandlingEventsRequest.ts deleted file mode 100644 index 3f3f4d31..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ListHandlingEventsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "123" - * } - */ -export interface ListHandlingEventsRequest { - /** The identifier for the conversation as given by Intercom. */ - id: 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 deleted file mode 100644 index 54ff3cf5..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts +++ /dev/null @@ -1,60 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 3653ec6d..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts +++ /dev/null @@ -1,75 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 1d207c59..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1, - * display_as: "plaintext", - * include_translations: true - * } - */ -export interface RetrieveConversationRequest { - /** The id of the conversation to target */ - id: number; - /** Set to plaintext to retrieve conversation messages in plain text. This affects both the body and subject fields. */ - display_as?: string; - /** If set to true, conversation parts will be translated to the detected language of the conversation. */ - include_translations?: boolean; -} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts deleted file mode 100644 index 9e2a3dea..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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. This affects both the body and subject fields. */ - 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; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ - company_id?: string; -} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/index.ts b/src/api/resources/unstable/resources/conversations/client/requests/index.ts deleted file mode 100644 index 3733a95d..00000000 --- a/src/api/resources/unstable/resources/conversations/client/requests/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type { AttachContactToConversationRequest } from "./AttachContactToConversationRequest.js"; -export type { ConvertConversationToTicketRequest } from "./ConvertConversationToTicketRequest.js"; -export type { CreateConversationRequest } from "./CreateConversationRequest.js"; -export type { DeleteConversationRequest } from "./DeleteConversationRequest.js"; -export type { DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest.js"; -export type { ListConversationsRequest } from "./ListConversationsRequest.js"; -export type { ListHandlingEventsRequest } from "./ListHandlingEventsRequest.js"; -export type { ManageConversationRequest } from "./ManageConversationRequest.js"; -export type { ReplyConversationRequest } from "./ReplyConversationRequest.js"; -export type { RetrieveConversationRequest } from "./RetrieveConversationRequest.js"; -export type { UpdateConversationRequest } from "./UpdateConversationRequest.js"; diff --git a/src/api/resources/unstable/resources/conversations/index.ts b/src/api/resources/unstable/resources/conversations/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/conversations/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/conversations/types/Conversation.ts b/src/api/resources/unstable/resources/conversations/types/Conversation.ts deleted file mode 100644 index d53ea2a2..00000000 --- a/src/api/resources/unstable/resources/conversations/types/Conversation.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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; - /** The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. */ - company_id?: string; - /** The company associated with the conversation. */ - company?: Intercom.unstable.Company; - 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 const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** If marked as priority, it will return priority or else not_priority. */ - export const Priority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type Priority = (typeof Priority)[keyof typeof Priority]; -} diff --git a/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts b/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts deleted file mode 100644 index ec011db3..00000000 --- a/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index 7f9a27b5..00000000 --- a/src/api/resources/unstable/resources/conversations/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Conversation.js"; -export * from "./ManageConversationRequestBody.js"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts b/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts deleted file mode 100644 index fdb99c2e..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts +++ /dev/null @@ -1,434 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CustomChannelEventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class CustomChannelEventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomChannelEventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.CustomChannelBaseEvent} request - * @param {CustomChannelEventsClient.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?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions)); - } - - private async __notifyNewConversation( - request: Intercom.unstable.CustomChannelBaseEvent, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_conversation", - ); - } - - /** - * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyNewMessageRequest} request - * @param {CustomChannelEventsClient.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?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions)); - } - - private async __notifyNewMessage( - request: Intercom.unstable.NotifyNewMessageRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_new_message", - ); - } - - /** - * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyQuickReplySelectedRequest} request - * @param {CustomChannelEventsClient.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?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions)); - } - - private async __notifyQuickReplySelected( - request: Intercom.unstable.NotifyQuickReplySelectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_quick_reply_selected", - ); - } - - /** - * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. - * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. - * - * @param {Intercom.unstable.NotifyAttributeCollectedRequest} request - * @param {CustomChannelEventsClient.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?: CustomChannelEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions)); - } - - private async __notifyAttributeCollected( - request: Intercom.unstable.NotifyAttributeCollectedRequest, - requestOptions?: CustomChannelEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_channel_events/notify_attribute_collected", - ); - } -} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/index.ts b/src/api/resources/unstable/resources/customChannelEvents/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts deleted file mode 100644 index f0ad7f82..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 8a4f252a..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 049df316..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 702922d9..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type { NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest.js"; -export type { NotifyNewMessageRequest } from "./NotifyNewMessageRequest.js"; -export type { NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest.js"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/index.ts b/src/api/resources/unstable/resources/customChannelEvents/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/customChannelEvents/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts b/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts deleted file mode 100644 index a8ff8f05..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts +++ /dev/null @@ -1,462 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace CustomObjectInstancesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * 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 CustomObjectInstancesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CustomObjectInstancesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Fetch a Custom Object Instance by external_id. - * - * @param {Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest} request - * @param {CustomObjectInstancesClient.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?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__getCustomObjectInstancesByExternalId(request, requestOptions), - ); - } - - private async __getCustomObjectInstancesByExternalId( - request: Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; - const _queryParams: Record = {}; - _queryParams.external_id = externalId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Create or update a custom object instance - * - * @param {Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest} request - * @param {CustomObjectInstancesClient.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?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createCustomObjectInstances(request, requestOptions)); - } - - private async __createCustomObjectInstances( - request: Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Delete a single Custom Object instance by external_id. - * - * @param {Intercom.unstable.DeleteCustomObjectInstancesByIdRequest} request - * @param {CustomObjectInstancesClient.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?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCustomObjectInstancesById(request, requestOptions)); - } - - private async __deleteCustomObjectInstancesById( - request: Intercom.unstable.DeleteCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; - const _queryParams: Record = {}; - _queryParams.external_id = externalId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/custom_object_instances/{custom_object_type_identifier}", - ); - } - - /** - * Fetch a Custom Object Instance by id. - * - * @param {Intercom.unstable.GetCustomObjectInstancesByIdRequest} request - * @param {CustomObjectInstancesClient.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?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getCustomObjectInstancesById(request, requestOptions)); - } - - private async __getCustomObjectInstancesById( - request: Intercom.unstable.GetCustomObjectInstancesByIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/custom_object_instances/{custom_object_type_identifier}/{id}", - ); - } - - /** - * Delete a single Custom Object instance using the Intercom defined id. - * - * @param {Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest} request - * @param {CustomObjectInstancesClient.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?: CustomObjectInstancesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise( - this.__deleteCustomObjectInstancesByExternalId(request, requestOptions), - ); - } - - private async __deleteCustomObjectInstancesByExternalId( - request: Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest, - requestOptions?: CustomObjectInstancesClient.RequestOptions, - ): Promise> { - const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `custom_object_instances/${core.url.encodePathParam(customObjectTypeIdentifier)}/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/custom_object_instances/{custom_object_type_identifier}/{id}", - ); - } -} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/index.ts b/src/api/resources/unstable/resources/customObjectInstances/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts deleted file mode 100644 index 97fa7ad7..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index 4a66d40e..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index d97bc1ce..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 deleted file mode 100644 index 2d9d0fe3..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 deleted file mode 100644 index 69c8d4cf..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 07816781..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { CreateOrUpdateCustomObjectInstanceRequest } from "./CreateOrUpdateCustomObjectInstanceRequest.js"; -export type { DeleteCustomObjectInstancesByExternalIdRequest } from "./DeleteCustomObjectInstancesByExternalIdRequest.js"; -export type { DeleteCustomObjectInstancesByIdRequest } from "./DeleteCustomObjectInstancesByIdRequest.js"; -export type { GetCustomObjectInstancesByExternalIdRequest } from "./GetCustomObjectInstancesByExternalIdRequest.js"; -export type { GetCustomObjectInstancesByIdRequest } from "./GetCustomObjectInstancesByIdRequest.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/index.ts b/src/api/resources/unstable/resources/customObjectInstances/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts deleted file mode 100644 index a4363acf..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 deleted file mode 100644 index 861f9ce5..00000000 --- a/src/api/resources/unstable/resources/customObjectInstances/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./CustomObjectInstance.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/client/Client.ts b/src/api/resources/unstable/resources/dataAttributes/client/Client.ts deleted file mode 100644 index 1778c2d1..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/client/Client.ts +++ /dev/null @@ -1,278 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace DataAttributesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Data Attributes - */ -export class DataAttributesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: DataAttributesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.dataAttributes.lisDataAttributes({ - * model: "contact", - * include_archived: true - * }) - */ - public lisDataAttributes( - request: Intercom.unstable.LisDataAttributesRequest = {}, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__lisDataAttributes(request, requestOptions)); - } - - private async __lisDataAttributes( - request: Intercom.unstable.LisDataAttributesRequest = {}, - requestOptions?: DataAttributesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "data_attributes", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/data_attributes"); - } - - /** - * You can create a data attributes for a `contact` or a `company`. - * - * @param {unknown} request - * @param {DataAttributesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.dataAttributes.createDataAttribute({ - * "key": "value" - * }) - */ - public createDataAttribute( - request?: unknown, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createDataAttribute(request, requestOptions)); - } - - private async __createDataAttribute( - request?: unknown, - requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "data_attributes", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/data_attributes"); - } - - /** - * - * 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 {DataAttributesClient.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, - * body: { - * "key": "value" - * } - * }) - */ - public updateDataAttribute( - request: Intercom.unstable.UpdateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateDataAttribute(request, requestOptions)); - } - - private async __updateDataAttribute( - request: Intercom.unstable.UpdateDataAttributeRequest, - requestOptions?: DataAttributesClient.RequestOptions, - ): Promise> { - const { id, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `data_attributes/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/data_attributes/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/index.ts b/src/api/resources/unstable/resources/dataAttributes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts deleted file mode 100644 index 89b6ac5f..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @example - * { - * model: "contact", - * include_archived: true - * } - */ -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 deleted file mode 100644 index a2d7f595..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1, - * body: { - * "key": "value" - * } - * } - */ -export interface UpdateDataAttributeRequest { - /** The data attribute id */ - id: number; - body?: unknown; -} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts deleted file mode 100644 index 7776c48b..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { LisDataAttributesRequest } from "./LisDataAttributesRequest.js"; -export type { UpdateDataAttributeRequest } from "./UpdateDataAttributeRequest.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/index.ts b/src/api/resources/unstable/resources/dataAttributes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts deleted file mode 100644 index 090b36d1..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts +++ /dev/null @@ -1,59 +0,0 @@ -// 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 const Model = { - Contact: "contact", - Company: "company", - } as const; - export type Model = (typeof Model)[keyof typeof Model]; - /** The data type of the attribute. */ - export const DataType = { - String: "string", - Integer: "integer", - Float: "float", - Boolean: "boolean", - Date: "date", - } as const; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts b/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts deleted file mode 100644 index 06e53b91..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export const LisDataAttributesRequestModel = { - Contact: "contact", - Company: "company", - Conversation: "conversation", -} as const; -export type LisDataAttributesRequestModel = - (typeof LisDataAttributesRequestModel)[keyof typeof LisDataAttributesRequestModel]; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/index.ts b/src/api/resources/unstable/resources/dataAttributes/types/index.ts deleted file mode 100644 index 7e5f4e72..00000000 --- a/src/api/resources/unstable/resources/dataAttributes/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataAttribute.js"; -export * from "./LisDataAttributesRequestModel.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/client/Client.ts b/src/api/resources/unstable/resources/dataEvents/client/Client.ts deleted file mode 100644 index ad66e987..00000000 --- a/src/api/resources/unstable/resources/dataEvents/client/Client.ts +++ /dev/null @@ -1,308 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import { toJson } from "../../../../../../core/json.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace DataEventsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Data Events - */ -export class DataEventsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: DataEventsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {DataEventsClient.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?: DataEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__lisDataEvents(request, requestOptions)); - } - - private async __lisDataEvents( - request: Intercom.unstable.LisDataEventsRequest, - requestOptions?: DataEventsClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/events"); - } - - /** - * - * 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 {DataEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.dataEvents.createDataEvent({ - * "key": "value" - * }) - */ - public createDataEvent( - request?: Intercom.CreateDataEventRequestTwo, - requestOptions?: DataEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createDataEvent(request, requestOptions)); - } - - private async __createDataEvent( - request?: Intercom.CreateDataEventRequestTwo, - requestOptions?: DataEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events"); - } - - /** - * 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 {DataEventsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.dataEvents.dataEventSummaries() - */ - public dataEventSummaries( - request: Intercom.unstable.CreateDataEventSummariesRequest = {}, - requestOptions?: DataEventsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__dataEventSummaries(request, requestOptions)); - } - - private async __dataEventSummaries( - request: Intercom.unstable.CreateDataEventSummariesRequest = {}, - requestOptions?: DataEventsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "events/summaries", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/events/summaries"); - } -} diff --git a/src/api/resources/unstable/resources/dataEvents/client/index.ts b/src/api/resources/unstable/resources/dataEvents/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/dataEvents/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts b/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts deleted file mode 100644 index ca40dbe7..00000000 --- a/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 0dc68cfc..00000000 --- a/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 06ee457d..00000000 --- a/src/api/resources/unstable/resources/dataEvents/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { CreateDataEventSummariesRequest } from "./CreateDataEventSummariesRequest.js"; -export type { LisDataEventsRequest } from "./LisDataEventsRequest.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/index.ts b/src/api/resources/unstable/resources/dataEvents/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/dataEvents/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts b/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts deleted file mode 100644 index a88a24e6..00000000 --- a/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 deleted file mode 100644 index 57f5d409..00000000 --- a/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index dbd381c1..00000000 --- a/src/api/resources/unstable/resources/dataEvents/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./DataEvent.js"; -export * from "./LisDataEventsRequestFilter.js"; diff --git a/src/api/resources/unstable/resources/dataExport/client/Client.ts b/src/api/resources/unstable/resources/dataExport/client/Client.ts deleted file mode 100644 index 9381c9f5..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/Client.ts +++ /dev/null @@ -1,313 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import type * as Intercom from "../../../../../index.js"; - -export declare namespace DataExportClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Data Exports - */ -export class DataExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: DataExportClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * 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 {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.dataExport.createDataExport({ - * created_at_after: 1734519776, - * created_at_before: 1734537776 - * }) - */ - public createDataExport( - request: Intercom.unstable.CreateDataExportsRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createDataExport(request, requestOptions)); - } - - private async __createDataExport( - request: Intercom.unstable.CreateDataExportsRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "export/content/data", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/export/content/data"); - } - - /** - * 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 {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.dataExport.getDataExport({ - * job_identifier: "job_identifier" - * }) - */ - public getDataExport( - request: Intercom.unstable.GetDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getDataExport(request, requestOptions)); - } - - private async __getDataExport( - request: Intercom.unstable.GetDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/content/data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/export/content/data/{job_identifier}", - ); - } - - /** - * You can cancel your job - * - * @param {Intercom.unstable.CancelDataExportRequest} request - * @param {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.dataExport.cancelDataExport({ - * job_identifier: "job_identifier" - * }) - */ - public cancelDataExport( - request: Intercom.unstable.CancelDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__cancelDataExport(request, requestOptions)); - } - - private async __cancelDataExport( - request: Intercom.unstable.CancelDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/cancel/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "POST", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/export/cancel/{job_identifier}", - ); - } - - /** - * 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 {DataExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.dataExport.downloadDataExport({ - * job_identifier: "job_identifier" - * }) - */ - public downloadDataExport( - request: Intercom.unstable.DownloadDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__downloadDataExport(request, requestOptions)); - } - - private async __downloadDataExport( - request: Intercom.unstable.DownloadDataExportRequest, - requestOptions?: DataExportClient.RequestOptions, - ): Promise> { - const { job_identifier: jobIdentifier } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `download/content/data/${core.url.encodePathParam(jobIdentifier)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/download/content/data/{job_identifier}", - ); - } -} diff --git a/src/api/resources/unstable/resources/dataExport/client/index.ts b/src/api/resources/unstable/resources/dataExport/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts b/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts deleted file mode 100644 index 4e387ec1..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 8854b7c9..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 98aab0f3..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index e75f9c9d..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 4a322611..00000000 --- a/src/api/resources/unstable/resources/dataExport/client/requests/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type { CancelDataExportRequest } from "./CancelDataExportRequest.js"; -export type { CreateDataExportsRequest } from "./CreateDataExportsRequest.js"; -export type { DownloadDataExportRequest } from "./DownloadDataExportRequest.js"; -export type { GetDataExportRequest } from "./GetDataExportRequest.js"; diff --git a/src/api/resources/unstable/resources/dataExport/index.ts b/src/api/resources/unstable/resources/dataExport/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/dataExport/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/dataExport/types/DataExport.ts b/src/api/resources/unstable/resources/dataExport/types/DataExport.ts deleted file mode 100644 index c846e2bb..00000000 --- a/src/api/resources/unstable/resources/dataExport/types/DataExport.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 const Status = { - Pending: "pending", - InProgress: "in_progress", - Failed: "failed", - Completed: "completed", - NoData: "no_data", - Canceled: "canceled", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/dataExport/types/index.ts b/src/api/resources/unstable/resources/dataExport/types/index.ts deleted file mode 100644 index 881ccc6c..00000000 --- a/src/api/resources/unstable/resources/dataExport/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./DataExport.js"; diff --git a/src/api/resources/unstable/resources/emails/client/Client.ts b/src/api/resources/unstable/resources/emails/client/Client.ts deleted file mode 100644 index 80dc6bdf..00000000 --- a/src/api/resources/unstable/resources/emails/client/Client.ts +++ /dev/null @@ -1,166 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace EmailsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Emails - */ -export class EmailsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: EmailsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Lists all sender email address settings for the workspace - * - * @param {EmailsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.emails.listEmails() - */ - public listEmails( - requestOptions?: EmailsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listEmails(requestOptions)); - } - - private async __listEmails( - requestOptions?: EmailsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "emails", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.EmailList, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/emails"); - } - - /** - * Fetches a specific email setting by its unique identifier - * - * @param {Intercom.unstable.RetrieveEmailRequest} request - * @param {EmailsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.emails.retrieveEmail({ - * id: "id" - * }) - */ - public retrieveEmail( - request: Intercom.unstable.RetrieveEmailRequest, - requestOptions?: EmailsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveEmail(request, requestOptions)); - } - - private async __retrieveEmail( - request: Intercom.unstable.RetrieveEmailRequest, - requestOptions?: EmailsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `emails/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.EmailSetting, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/emails/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/emails/client/index.ts b/src/api/resources/unstable/resources/emails/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/emails/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/emails/client/requests/RetrieveEmailRequest.ts b/src/api/resources/unstable/resources/emails/client/requests/RetrieveEmailRequest.ts deleted file mode 100644 index 7e8d58ab..00000000 --- a/src/api/resources/unstable/resources/emails/client/requests/RetrieveEmailRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "id" - * } - */ -export interface RetrieveEmailRequest { - /** The unique identifier of the email setting */ - id: string; -} diff --git a/src/api/resources/unstable/resources/emails/client/requests/index.ts b/src/api/resources/unstable/resources/emails/client/requests/index.ts deleted file mode 100644 index 28137871..00000000 --- a/src/api/resources/unstable/resources/emails/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { RetrieveEmailRequest } from "./RetrieveEmailRequest.js"; diff --git a/src/api/resources/unstable/resources/emails/index.ts b/src/api/resources/unstable/resources/emails/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/emails/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/emails/types/EmailList.ts b/src/api/resources/unstable/resources/emails/types/EmailList.ts deleted file mode 100644 index 41aa6d09..00000000 --- a/src/api/resources/unstable/resources/emails/types/EmailList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A list of email settings - */ -export interface EmailList { - /** The type of object */ - type?: string; - data?: Intercom.unstable.EmailSetting[]; -} diff --git a/src/api/resources/unstable/resources/emails/types/EmailSetting.ts b/src/api/resources/unstable/resources/emails/types/EmailSetting.ts deleted file mode 100644 index bd584aec..00000000 --- a/src/api/resources/unstable/resources/emails/types/EmailSetting.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Represents a sender email address configuration - */ -export interface EmailSetting { - /** The type of object */ - type?: string; - /** Unique email setting identifier */ - id?: string; - /** Full sender email address */ - email?: string; - /** Whether the email address has been verified */ - verified?: boolean; - /** Domain portion of the email address */ - domain?: string; - /** Associated brand identifier */ - brand_id?: string; - /** Whether email forwarding is active */ - forwarding_enabled?: boolean; - /** Unix timestamp of last forwarded email received (null if never) */ - forwarded_email_last_received_at?: number; - /** Unix timestamp of creation */ - created_at?: number; - /** Unix timestamp of last modification */ - updated_at?: number; -} diff --git a/src/api/resources/unstable/resources/emails/types/index.ts b/src/api/resources/unstable/resources/emails/types/index.ts deleted file mode 100644 index ffc91a1b..00000000 --- a/src/api/resources/unstable/resources/emails/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./EmailList.js"; -export * from "./EmailSetting.js"; diff --git a/src/api/resources/unstable/resources/export/client/Client.ts b/src/api/resources/unstable/resources/export/client/Client.ts deleted file mode 100644 index af0ecc87..00000000 --- a/src/api/resources/unstable/resources/export/client/Client.ts +++ /dev/null @@ -1,176 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace ExportClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class ExportClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: ExportClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * @param {Intercom.unstable.PostExportReportingDataEnqueueRequest} request - * @param {ExportClient.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_started_at"], - * start_time: 1717490000, - * end_time: 1717510000 - * }) - */ - public enqueueANewReportingDataExportJob( - request: Intercom.unstable.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions)); - } - - private async __enqueueANewReportingDataExportJob( - request: Intercom.unstable.PostExportReportingDataEnqueueRequest, - requestOptions?: ExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "export/reporting_data/enqueue", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/export/reporting_data/enqueue", - ); - } - - /** - * @param {ExportClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @example - * await client.unstable.export.listAvailableDatasetsAndAttributes() - */ - public listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions)); - } - - private async __listAvailableDatasetsAndAttributes( - requestOptions?: ExportClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (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: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/export/reporting_data/get_datasets", - ); - } -} diff --git a/src/api/resources/unstable/resources/export/client/index.ts b/src/api/resources/unstable/resources/export/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/export/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts deleted file mode 100644 index 57767a44..00000000 --- a/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * dataset_id: "conversation", - * attribute_ids: ["conversation_id", "conversation_started_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 deleted file mode 100644 index a18772b7..00000000 --- a/src/api/resources/unstable/resources/export/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { PostExportReportingDataEnqueueRequest } from "./PostExportReportingDataEnqueueRequest.js"; diff --git a/src/api/resources/unstable/resources/export/index.ts b/src/api/resources/unstable/resources/export/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/export/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts deleted file mode 100644 index 725ac29a..00000000 --- a/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts +++ /dev/null @@ -1,31 +0,0 @@ -// 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 deleted file mode 100644 index c15d988e..00000000 --- a/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 27e82ed3..00000000 --- a/src/api/resources/unstable/resources/export/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./GetExportReportingDataGetDatasetsResponse.js"; -export * from "./PostExportReportingDataEnqueueResponse.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/client/Client.ts b/src/api/resources/unstable/resources/helpCenter/client/Client.ts deleted file mode 100644 index 73d06f5d..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/Client.ts +++ /dev/null @@ -1,554 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace HelpCenterClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Help Center - */ -export class HelpCenterClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: HelpCenterClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.helpCenter.listAllCollections() - */ - public listAllCollections( - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listAllCollections(requestOptions)); - } - - private async __listAllCollections( - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/collections", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections"); - } - - /** - * 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 {HelpCenterClient.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?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createCollection(request, requestOptions)); - } - - private async __createCollection( - request: Intercom.unstable.CreateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/collections", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/help_center/collections"); - } - - /** - * 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 {HelpCenterClient.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?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveCollection(request, requestOptions)); - } - - private async __retrieveCollection( - request: Intercom.unstable.RetrieveCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/collections/{id}"); - } - - /** - * 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 {HelpCenterClient.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?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateCollection(request, requestOptions)); - } - - private async __updateCollection( - request: Intercom.unstable.UpdateCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/help_center/collections/{id}"); - } - - /** - * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. - * - * @param {Intercom.unstable.DeleteCollectionRequest} request - * @param {HelpCenterClient.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?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteCollection(request, requestOptions)); - } - - private async __deleteCollection( - request: Intercom.unstable.DeleteCollectionRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/collections/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/help_center/collections/{id}", - ); - } - - /** - * 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 {HelpCenterClient.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?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveHelpCenter(request, requestOptions)); - } - - private async __retrieveHelpCenter( - request: Intercom.unstable.RetrieveHelpCenterRequest, - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `help_center/help_centers/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/help_center/help_centers/{id}", - ); - } - - /** - * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. - * - * @param {HelpCenterClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.helpCenter.listHelpCenters() - */ - public listHelpCenters( - requestOptions?: HelpCenterClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listHelpCenters(requestOptions)); - } - - private async __listHelpCenters( - requestOptions?: HelpCenterClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/help_centers", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/help_center/help_centers"); - } -} diff --git a/src/api/resources/unstable/resources/helpCenter/client/index.ts b/src/api/resources/unstable/resources/helpCenter/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts deleted file mode 100644 index 79a825bf..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index fb363f5c..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index b444789d..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index b4787e86..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 9caeacc0..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index d2d1c0aa..00000000 --- a/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { CreateCollectionRequest } from "./CreateCollectionRequest.js"; -export type { DeleteCollectionRequest } from "./DeleteCollectionRequest.js"; -export type { RetrieveCollectionRequest } from "./RetrieveCollectionRequest.js"; -export type { RetrieveHelpCenterRequest } from "./RetrieveHelpCenterRequest.js"; -export type { UpdateCollectionRequest } from "./UpdateCollectionRequest.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/index.ts b/src/api/resources/unstable/resources/helpCenter/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/helpCenter/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/helpCenter/types/Collection.ts b/src/api/resources/unstable/resources/helpCenter/types/Collection.ts deleted file mode 100644 index 475021d4..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/Collection.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 3715e87f..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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; - /** The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. */ - url?: string; - /** Custom domain configured for the help center */ - custom_domain?: string; -} diff --git a/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts deleted file mode 100644 index 75bc4786..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 097e7b49..00000000 --- a/src/api/resources/unstable/resources/helpCenter/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Collection.js"; -export * from "./HelpCenter.js"; -export * from "./HelpCenterList.js"; diff --git a/src/api/resources/unstable/resources/index.ts b/src/api/resources/unstable/resources/index.ts deleted file mode 100644 index e821213e..00000000 --- a/src/api/resources/unstable/resources/index.ts +++ /dev/null @@ -1,95 +0,0 @@ -export * from "./admins/client/requests/index.js"; -export * as admins from "./admins/index.js"; -export * from "./admins/types/index.js"; -export * as aiAgent from "./aiAgent/index.js"; -export * from "./aiAgent/types/index.js"; -export * from "./aiContent/client/requests/index.js"; -export * as aiContent from "./aiContent/index.js"; -export * from "./aiContent/types/index.js"; -export * as aiContentSource from "./aiContentSource/index.js"; -export * from "./aiContentSource/types/index.js"; -export * from "./articles/client/requests/index.js"; -export * as articles from "./articles/index.js"; -export * from "./articles/types/index.js"; -export * as awayStatusReasons from "./awayStatusReasons/index.js"; -export * from "./brands/client/requests/index.js"; -export * as brands from "./brands/index.js"; -export * from "./brands/types/index.js"; -export * from "./calls/client/requests/index.js"; -export * as calls from "./calls/index.js"; -export * from "./calls/types/index.js"; -export * from "./companies/client/requests/index.js"; -export * as companies from "./companies/index.js"; -export * from "./companies/types/index.js"; -export * from "./contacts/client/requests/index.js"; -export * as contacts from "./contacts/index.js"; -export * from "./contacts/types/index.js"; -export * from "./conversations/client/requests/index.js"; -export * as conversations from "./conversations/index.js"; -export * from "./conversations/types/index.js"; -export * from "./customChannelEvents/client/requests/index.js"; -export * as customChannelEvents from "./customChannelEvents/index.js"; -export * from "./customObjectInstances/client/requests/index.js"; -export * as customObjectInstances from "./customObjectInstances/index.js"; -export * from "./customObjectInstances/types/index.js"; -export * from "./dataAttributes/client/requests/index.js"; -export * as dataAttributes from "./dataAttributes/index.js"; -export * from "./dataAttributes/types/index.js"; -export * from "./dataEvents/client/requests/index.js"; -export * as dataEvents from "./dataEvents/index.js"; -export * from "./dataEvents/types/index.js"; -export * from "./dataExport/client/requests/index.js"; -export * as dataExport from "./dataExport/index.js"; -export * from "./dataExport/types/index.js"; -export * from "./emails/client/requests/index.js"; -export * as emails from "./emails/index.js"; -export * from "./emails/types/index.js"; -export * from "./export/client/requests/index.js"; -export * as export_ from "./export/index.js"; -export * from "./export/types/index.js"; -export * from "./helpCenter/client/requests/index.js"; -export * as helpCenter from "./helpCenter/index.js"; -export * from "./helpCenter/types/index.js"; -export * from "./internalArticles/client/requests/index.js"; -export * as internalArticles from "./internalArticles/index.js"; -export * from "./internalArticles/types/index.js"; -export * from "./jobs/client/requests/index.js"; -export * as jobs from "./jobs/index.js"; -export * from "./jobs/types/index.js"; -export * from "./macros/client/requests/index.js"; -export * as macros from "./macros/index.js"; -export * from "./macros/types/index.js"; -export * from "./messages/client/requests/index.js"; -export * as messages from "./messages/index.js"; -export * from "./messages/types/index.js"; -export * from "./news/client/requests/index.js"; -export * as news from "./news/index.js"; -export * from "./news/types/index.js"; -export * from "./notes/client/requests/index.js"; -export * as notes from "./notes/index.js"; -export * from "./notes/types/index.js"; -export * from "./segments/client/requests/index.js"; -export * as segments from "./segments/index.js"; -export * from "./segments/types/index.js"; -export * from "./subscriptionTypes/client/requests/index.js"; -export * as subscriptionTypes from "./subscriptionTypes/index.js"; -export * from "./subscriptionTypes/types/index.js"; -export * as switch_ from "./switch/index.js"; -export * from "./tags/client/requests/index.js"; -export * as tags from "./tags/index.js"; -export * from "./tags/types/index.js"; -export * from "./teams/client/requests/index.js"; -export * as teams from "./teams/index.js"; -export * from "./teams/types/index.js"; -export * as ticketStates from "./ticketStates/index.js"; -export * from "./tickets/client/requests/index.js"; -export * as tickets from "./tickets/index.js"; -export * from "./tickets/types/index.js"; -export * from "./ticketTypeAttributes/client/requests/index.js"; -export * as ticketTypeAttributes from "./ticketTypeAttributes/index.js"; -export * from "./ticketTypes/client/requests/index.js"; -export * as ticketTypes from "./ticketTypes/index.js"; -export * from "./visitors/client/requests/index.js"; -export * as visitors from "./visitors/index.js"; -export * from "./workflows/client/requests/index.js"; -export * as workflows from "./workflows/index.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/client/Client.ts b/src/api/resources/unstable/resources/internalArticles/client/Client.ts deleted file mode 100644 index bcfe5c32..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/Client.ts +++ /dev/null @@ -1,491 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace InternalArticlesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Internal Articles - */ -export class InternalArticlesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: InternalArticlesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. - * - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.internalArticles.listInternalArticles() - */ - public listInternalArticles( - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listInternalArticles(requestOptions)); - } - - private async __listInternalArticles( - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.InternalArticleList, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/internal_articles"); - } - - /** - * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. - * - * @param {Intercom.unstable.CreateInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.internalArticles.createInternalArticle({ - * title: "Thanks for everything", - * body: "Body of the Article", - * author_id: 991266252, - * owner_id: 991266252 - * }) - * - * @example - * await client.unstable.internalArticles.createInternalArticle({ - * title: "Thanks for everything", - * body: "Body of the Internal Article", - * author_id: 1295, - * owner_id: 1295 - * }) - */ - public createInternalArticle( - request?: Intercom.unstable.CreateInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createInternalArticle(request, requestOptions)); - } - - private async __createInternalArticle( - request?: Intercom.unstable.CreateInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/internal_articles"); - } - - /** - * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.unstable.RetrieveInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.internalArticles.retrieveInternalArticle({ - * id: 1 - * }) - */ - public retrieveInternalArticle( - request: Intercom.unstable.RetrieveInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveInternalArticle(request, requestOptions)); - } - - private async __retrieveInternalArticle( - request: Intercom.unstable.RetrieveInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/internal_articles/{id}"); - } - - /** - * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.unstable.UpdateInternalArticleRequestBody} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.internalArticles.updateInternalArticle({ - * id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * }) - */ - public updateInternalArticle( - request: Intercom.unstable.UpdateInternalArticleRequestBody, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateInternalArticle(request, requestOptions)); - } - - private async __updateInternalArticle( - request: Intercom.unstable.UpdateInternalArticleRequestBody, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.InternalArticle, 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/internal_articles/{id}"); - } - - /** - * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. - * - * @param {Intercom.unstable.DeleteInternalArticleRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.internalArticles.deleteInternalArticle({ - * id: 1 - * }) - */ - public deleteInternalArticle( - request: Intercom.unstable.DeleteInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteInternalArticle(request, requestOptions)); - } - - private async __deleteInternalArticle( - request: Intercom.unstable.DeleteInternalArticleRequest, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `internal_articles/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.DeletedInternalArticleObject, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/internal_articles/{id}"); - } - - /** - * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. - * - * @param {Intercom.unstable.SearchInternalArticlesRequest} request - * @param {InternalArticlesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.internalArticles.searchInternalArticles({ - * folder_id: "folder_id" - * }) - */ - public searchInternalArticles( - request: Intercom.unstable.SearchInternalArticlesRequest = {}, - requestOptions?: InternalArticlesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchInternalArticles(request, requestOptions)); - } - - private async __searchInternalArticles( - request: Intercom.unstable.SearchInternalArticlesRequest = {}, - requestOptions?: InternalArticlesClient.RequestOptions, - ): Promise> { - const { folder_id: folderId } = request; - const _queryParams: Record = {}; - if (folderId != null) { - _queryParams.folder_id = folderId; - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "internal_articles/search", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Intercom.unstable.InternalArticleSearchResponse, - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/internal_articles/search"); - } -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/index.ts b/src/api/resources/unstable/resources/internalArticles/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts deleted file mode 100644 index dd3f7586..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/DeleteInternalArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1 - * } - */ -export interface DeleteInternalArticleRequest { - /** The unique identifier for the internal article which is given by Intercom. */ - id: number; -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts deleted file mode 100644 index bf5d0ece..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/RetrieveInternalArticleRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1 - * } - */ -export interface RetrieveInternalArticleRequest { - /** The unique identifier for the article which is given by Intercom. */ - id: number; -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts deleted file mode 100644 index 6f80cf05..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/SearchInternalArticlesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * folder_id: "folder_id" - * } - */ -export interface SearchInternalArticlesRequest { - /** The ID of the folder to search in. */ - folder_id?: string; -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts deleted file mode 100644 index ffd0c32d..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/UpdateInternalArticleRequestBody.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - * - * @example - * { - * id: 1, - * title: "Christmas is here!", - * body: "

New gifts in store for the jolly season

" - * } - */ -export interface UpdateInternalArticleRequestBody { - /** The unique identifier for the internal article which is given by Intercom. */ - id: number; - /** The title of the article. */ - title?: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id?: number; - /** The id of the author of the article. */ - owner_id?: number; -} diff --git a/src/api/resources/unstable/resources/internalArticles/client/requests/index.ts b/src/api/resources/unstable/resources/internalArticles/client/requests/index.ts deleted file mode 100644 index 677bd9fa..00000000 --- a/src/api/resources/unstable/resources/internalArticles/client/requests/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type { DeleteInternalArticleRequest } from "./DeleteInternalArticleRequest.js"; -export type { RetrieveInternalArticleRequest } from "./RetrieveInternalArticleRequest.js"; -export type { SearchInternalArticlesRequest } from "./SearchInternalArticlesRequest.js"; -export type { UpdateInternalArticleRequestBody } from "./UpdateInternalArticleRequestBody.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/index.ts b/src/api/resources/unstable/resources/internalArticles/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/internalArticles/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts b/src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts deleted file mode 100644 index b906ff6f..00000000 --- a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleListItem.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The data returned about your internal articles when you list them. - */ -export interface InternalArticleListItem { - /** The type of object - `internal_article`. */ - type?: "internal_article"; - /** The unique identifier for the article which is given by Intercom. */ - id?: string; - /** The title of the article. */ - title?: string; - /** The body of the article in HTML. */ - body?: string; - /** The id of the owner of the article. */ - owner_id?: number; - /** The id of the author of the article. */ - author_id?: number; - /** The time when the article was created. */ - created_at?: number; - /** The time when the article was last updated. */ - updated_at?: number; - /** The default locale of the article. */ - locale?: string; -} diff --git a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts b/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts deleted file mode 100644 index b7790005..00000000 --- a/src/api/resources/unstable/resources/internalArticles/types/InternalArticleSearchResponse.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * The results of an Internal Article search - */ -export interface InternalArticleSearchResponse { - /** The type of the object - `list`. */ - type?: "list"; - /** The total number of Internal Articles matching the search query */ - total_count?: number; - /** An object containing the results of the search. */ - data?: InternalArticleSearchResponse.Data; - pages?: Intercom.unstable.CursorPages; -} - -export namespace InternalArticleSearchResponse { - /** - * An object containing the results of the search. - */ - export interface Data { - /** An array of Internal Article objects */ - internal_articles?: Intercom.unstable.InternalArticle[]; - } -} diff --git a/src/api/resources/unstable/resources/internalArticles/types/index.ts b/src/api/resources/unstable/resources/internalArticles/types/index.ts deleted file mode 100644 index aedeb96e..00000000 --- a/src/api/resources/unstable/resources/internalArticles/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./InternalArticleListItem.js"; -export * from "./InternalArticleSearchResponse.js"; diff --git a/src/api/resources/unstable/resources/jobs/client/Client.ts b/src/api/resources/unstable/resources/jobs/client/Client.ts deleted file mode 100644 index 232af1bd..00000000 --- a/src/api/resources/unstable/resources/jobs/client/Client.ts +++ /dev/null @@ -1,101 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace JobsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about jobs - */ -export class JobsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: JobsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve the status of job execution. - * - * @param {Intercom.unstable.JobsStatusRequest} request - * @param {JobsClient.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?: JobsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__status(request, requestOptions)); - } - - private async __status( - request: Intercom.unstable.JobsStatusRequest, - requestOptions?: JobsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `jobs/status/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/jobs/status/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/jobs/client/index.ts b/src/api/resources/unstable/resources/jobs/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/jobs/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts b/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts deleted file mode 100644 index 80f53a81..00000000 --- a/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index bfed16f9..00000000 --- a/src/api/resources/unstable/resources/jobs/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { JobsStatusRequest } from "./JobsStatusRequest.js"; diff --git a/src/api/resources/unstable/resources/jobs/index.ts b/src/api/resources/unstable/resources/jobs/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/jobs/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/jobs/types/Jobs.ts b/src/api/resources/unstable/resources/jobs/types/Jobs.ts deleted file mode 100644 index c3e63585..00000000 --- a/src/api/resources/unstable/resources/jobs/types/Jobs.ts +++ /dev/null @@ -1,31 +0,0 @@ -// 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 const Status = { - Pending: "pending", - Success: "success", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; -} diff --git a/src/api/resources/unstable/resources/jobs/types/index.ts b/src/api/resources/unstable/resources/jobs/types/index.ts deleted file mode 100644 index c4ca9992..00000000 --- a/src/api/resources/unstable/resources/jobs/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Jobs.js"; diff --git a/src/api/resources/unstable/resources/macros/client/Client.ts b/src/api/resources/unstable/resources/macros/client/Client.ts deleted file mode 100644 index 60a0a207..00000000 --- a/src/api/resources/unstable/resources/macros/client/Client.ts +++ /dev/null @@ -1,230 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace MacrosClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Operations related to saved replies (macros) in conversations - */ -export class MacrosClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: MacrosClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all macros (saved replies) in your workspace for use in automating responses. - * - * The macros are returned in descending order by updated_at. - * - * **Pagination** - * - * This endpoint uses cursor-based pagination via the `starting_after` parameter. The cursor is a Base64-encoded JSON array containing `[updated_at, id]` of the last item from the previous page. - * - * **Placeholder Transformation** - * - * The API transforms Intercom placeholders to a more standard XML-like format: - * - From: `{{user.name | fallback: 'there'}}` - * - To: `` - * - * @param {Intercom.unstable.ListMacrosRequest} request - * @param {MacrosClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.BadRequestError} - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * - * @example - * await client.unstable.macros.listMacros({ - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * }) - */ - public listMacros( - request: Intercom.unstable.ListMacrosRequest = {}, - requestOptions?: MacrosClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listMacros(request, requestOptions)); - } - - private async __listMacros( - request: Intercom.unstable.ListMacrosRequest = {}, - requestOptions?: MacrosClient.RequestOptions, - ): Promise> { - const { per_page: perPage, starting_after: startingAfter, updated_since: updatedSince } = request; - const _queryParams: Record = {}; - if (perPage != null) { - _queryParams.per_page = perPage.toString(); - } - - if (startingAfter != null) { - _queryParams.starting_after = startingAfter; - } - - if (updatedSince != null) { - _queryParams.updated_since = updatedSince.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "macros", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.MacroList, 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, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/macros"); - } - - /** - * You can fetch a single macro (saved reply) by its ID. The macro will only be returned if it is visible to the authenticated user based on its visibility settings. - * - * **Visibility Rules** - * - * A macro is returned based on its `visible_to` setting: - * - `everyone`: Always visible to all team members - * - `specific_teams`: Only visible if the authenticated user belongs to one of the teams specified in `visible_to_team_ids` - * - * If a macro exists but is not visible to the authenticated user, a 404 error is returned. - * - * **Placeholder Transformation** - * - * The API transforms Intercom placeholders to a more standard XML-like format in the `body` field: - * - From: `{{user.name | fallback: 'there'}}` - * - To: `` - * - * Default values in placeholders are HTML-escaped for security. - * - * @param {Intercom.unstable.GetMacroRequest} request - * @param {MacrosClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.macros.getMacro({ - * id: "123" - * }) - */ - public getMacro( - request: Intercom.unstable.GetMacroRequest, - requestOptions?: MacrosClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getMacro(request, requestOptions)); - } - - private async __getMacro( - request: Intercom.unstable.GetMacroRequest, - requestOptions?: MacrosClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `macros/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.Macro | 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 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/macros/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/macros/client/index.ts b/src/api/resources/unstable/resources/macros/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/macros/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/macros/client/requests/GetMacroRequest.ts b/src/api/resources/unstable/resources/macros/client/requests/GetMacroRequest.ts deleted file mode 100644 index a90a0866..00000000 --- a/src/api/resources/unstable/resources/macros/client/requests/GetMacroRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "123" - * } - * - * @example - * { - * id: "123" - * } - * - * @example - * { - * id: "123" - * } - * - * @example - * { - * id: "123" - * } - */ -export interface GetMacroRequest { - /** The unique identifier of the macro */ - id: string; -} diff --git a/src/api/resources/unstable/resources/macros/client/requests/ListMacrosRequest.ts b/src/api/resources/unstable/resources/macros/client/requests/ListMacrosRequest.ts deleted file mode 100644 index caf7ed0d..00000000 --- a/src/api/resources/unstable/resources/macros/client/requests/ListMacrosRequest.ts +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - * - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - * - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - * - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - * - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - * - * @example - * { - * per_page: 1, - * starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - * updated_since: 1000000 - * } - */ -export interface ListMacrosRequest { - /** The number of results per page */ - per_page?: number; - /** Base64-encoded cursor containing [updated_at, id] for pagination */ - starting_after?: string; - /** Unix timestamp to filter macros updated after this time */ - updated_since?: number; -} diff --git a/src/api/resources/unstable/resources/macros/client/requests/index.ts b/src/api/resources/unstable/resources/macros/client/requests/index.ts deleted file mode 100644 index 10c97f9d..00000000 --- a/src/api/resources/unstable/resources/macros/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { GetMacroRequest } from "./GetMacroRequest.js"; -export type { ListMacrosRequest } from "./ListMacrosRequest.js"; diff --git a/src/api/resources/unstable/resources/macros/index.ts b/src/api/resources/unstable/resources/macros/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/macros/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/macros/types/Macro.ts b/src/api/resources/unstable/resources/macros/types/Macro.ts deleted file mode 100644 index b7941f1a..00000000 --- a/src/api/resources/unstable/resources/macros/types/Macro.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A macro is a pre-defined response template (saved reply) that can be used to quickly reply to conversations. - */ -export interface Macro { - /** String representing the object's type. Always has the value `macro`. */ - type?: "macro"; - /** The unique identifier for the macro. */ - id?: string; - /** The name of the macro. */ - name?: string; - /** The body of the macro in HTML format with placeholders transformed to XML-like format. */ - body?: string; - /** The plain text version of the macro body with original Intercom placeholder format. */ - body_text?: string; - /** The time the macro was created in ISO 8601 format. */ - created_at?: string; - /** The time the macro was last updated in ISO 8601 format. */ - updated_at?: string; - /** Who can view this macro. */ - visible_to?: Macro.VisibleTo; - /** The team IDs that can view this macro when visible_to is set to specific_teams. */ - visible_to_team_ids?: string[]; - /** Where the macro is available for use. */ - available_on?: Macro.AvailableOn.Item[]; -} - -export namespace Macro { - /** Who can view this macro. */ - export const VisibleTo = { - Everyone: "everyone", - SpecificTeams: "specific_teams", - } as const; - export type VisibleTo = (typeof VisibleTo)[keyof typeof VisibleTo]; - export type AvailableOn = AvailableOn.Item[]; - - export namespace AvailableOn { - export const Item = { - Inbox: "inbox", - Messenger: "messenger", - } as const; - export type Item = (typeof Item)[keyof typeof Item]; - } -} diff --git a/src/api/resources/unstable/resources/macros/types/MacroList.ts b/src/api/resources/unstable/resources/macros/types/MacroList.ts deleted file mode 100644 index 0694b02f..00000000 --- a/src/api/resources/unstable/resources/macros/types/MacroList.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * A paginated list of macros (saved replies) in the workspace. - */ -export interface MacroList { - /** Always list */ - type?: "list"; - /** The list of macro objects */ - data?: (Intercom.unstable.Macro | undefined)[]; - /** Pagination information */ - pages?: MacroList.Pages; -} - -export namespace MacroList { - /** - * Pagination information - */ - export interface Pages { - /** The type of pagination */ - type?: "pages"; - /** Number of results per page */ - per_page?: number; - /** Cursor for the next page */ - next?: Pages.Next; - } - - export namespace Pages { - /** - * Cursor for the next page - */ - export interface Next { - /** Base64-encoded cursor containing [updated_at, id] for pagination */ - starting_after?: string; - } - } -} diff --git a/src/api/resources/unstable/resources/macros/types/index.ts b/src/api/resources/unstable/resources/macros/types/index.ts deleted file mode 100644 index 46516f7b..00000000 --- a/src/api/resources/unstable/resources/macros/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./Macro.js"; -export * from "./MacroList.js"; diff --git a/src/api/resources/unstable/resources/messages/client/Client.ts b/src/api/resources/unstable/resources/messages/client/Client.ts deleted file mode 100644 index 95d1513f..00000000 --- a/src/api/resources/unstable/resources/messages/client/Client.ts +++ /dev/null @@ -1,381 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace MessagesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your messages - */ -export class MessagesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: MessagesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email, sms or whatsapp. - * - * > 🚧 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.unstable.CreateMessageRequest | undefined} request - * @param {MessagesClient.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": "991267817" - * }, - * "to": { - * "phone": 5547999998888, - * "name": "John Doe" - * }, - * "message_type": "whatsapp", - * "components": [ - * { - * "type": "BODY", - * "parameters": [ - * { - * "type": "text", - * "text": "Username 123" - * } - * ] - * } - * ], - * "template": "keep_live", - * "locale": "en" - * }) - * - * @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.unstable.CreateMessageRequest | undefined, - requestOptions?: MessagesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createMessage(request, requestOptions)); - } - - private async __createMessage( - request?: Intercom.unstable.CreateMessageRequest | undefined, - requestOptions?: MessagesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "messages", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request != null ? request : undefined, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/messages"); - } - - /** - * 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 {MessagesClient.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", - * per_page: 1, - * starting_after: "starting_after" - * }) - */ - public getWhatsAppMessageStatus( - request: Intercom.unstable.GetWhatsAppMessageStatusRequest, - requestOptions?: MessagesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getWhatsAppMessageStatus(request, requestOptions)); - } - - private async __getWhatsAppMessageStatus( - request: Intercom.unstable.GetWhatsAppMessageStatusRequest, - requestOptions?: MessagesClient.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 _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "messages/status", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/messages/status"); - } -} diff --git a/src/api/resources/unstable/resources/messages/client/index.ts b/src/api/resources/unstable/resources/messages/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/messages/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts b/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts deleted file mode 100644 index 4857f1ff..00000000 --- a/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * ruleset_id: "ruleset_id", - * per_page: 1, - * starting_after: "starting_after" - * } - */ -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 deleted file mode 100644 index 3571c87e..00000000 --- a/src/api/resources/unstable/resources/messages/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { GetWhatsAppMessageStatusRequest } from "./GetWhatsAppMessageStatusRequest.js"; diff --git a/src/api/resources/unstable/resources/messages/index.ts b/src/api/resources/unstable/resources/messages/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/messages/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/messages/types/Message.ts b/src/api/resources/unstable/resources/messages/types/Message.ts deleted file mode 100644 index 14710453..00000000 --- a/src/api/resources/unstable/resources/messages/types/Message.ts +++ /dev/null @@ -1,34 +0,0 @@ -// 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, sms or whatsapp. */ - 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, sms or whatsapp. */ - export const MessageType = { - Email: "email", - Inapp: "inapp", - Facebook: "facebook", - Twitter: "twitter", - Sms: "sms", - Whatsapp: "whatsapp", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/resources/unstable/resources/messages/types/index.ts b/src/api/resources/unstable/resources/messages/types/index.ts deleted file mode 100644 index e16d36b7..00000000 --- a/src/api/resources/unstable/resources/messages/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Message.js"; diff --git a/src/api/resources/unstable/resources/news/client/Client.ts b/src/api/resources/unstable/resources/news/client/Client.ts deleted file mode 100644 index a0463196..00000000 --- a/src/api/resources/unstable/resources/news/client/Client.ts +++ /dev/null @@ -1,622 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace NewsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your News - */ -export class NewsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: NewsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all news items - * - * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.news.listNewsItems() - */ - public listNewsItems( - requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listNewsItems(requestOptions)); - } - - private async __listNewsItems( - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/news_items", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/news_items"); - } - - /** - * You can create a news item - * - * @param {Intercom.unstable.NewsItemRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createNewsItem(request, requestOptions)); - } - - private async __createNewsItem( - request: Intercom.unstable.NewsItemRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/news_items", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/news/news_items"); - } - - /** - * You can fetch the details of a single news item. - * - * @param {Intercom.unstable.RetrieveNewsItemRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveNewsItem(request, requestOptions)); - } - - private async __retrieveNewsItem( - request: Intercom.unstable.RetrieveNewsItemRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/news_items/{id}"); - } - - /** - * @param {Intercom.unstable.UpdateNewsItemRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateNewsItem(request, requestOptions)); - } - - private async __updateNewsItem( - request: Intercom.unstable.UpdateNewsItemRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const { id, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/news/news_items/{id}"); - } - - /** - * You can delete a single news item. - * - * @param {Intercom.unstable.DeleteNewsItemRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteNewsItem(request, requestOptions)); - } - - private async __deleteNewsItem( - request: Intercom.unstable.DeleteNewsItemRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/news_items/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/news/news_items/{id}"); - } - - /** - * You can fetch a list of all news items that are live on a given newsfeed - * - * @param {Intercom.unstable.ListLiveNewsfeedItemsRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listLiveNewsfeedItems(request, requestOptions)); - } - - private async __listLiveNewsfeedItems( - request: Intercom.unstable.ListLiveNewsfeedItemsRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/newsfeeds/${core.url.encodePathParam(id)}/items`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/newsfeeds/{id}/items"); - } - - /** - * You can fetch a list of all newsfeeds - * - * @param {NewsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.news.listNewsfeeds() - */ - public listNewsfeeds( - requestOptions?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listNewsfeeds(requestOptions)); - } - - private async __listNewsfeeds( - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "news/newsfeeds", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/newsfeeds"); - } - - /** - * You can fetch the details of a single newsfeed - * - * @param {Intercom.unstable.RetrieveNewsfeedRequest} request - * @param {NewsClient.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?: NewsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveNewsfeed(request, requestOptions)); - } - - private async __retrieveNewsfeed( - request: Intercom.unstable.RetrieveNewsfeedRequest, - requestOptions?: NewsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `news/newsfeeds/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/news/newsfeeds/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/news/client/index.ts b/src/api/resources/unstable/resources/news/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/news/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts b/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts deleted file mode 100644 index e78e359e..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 80431667..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 4c61a48f..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index d7162aaa..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 8c96cdfa..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index d5c9a5f5..00000000 --- a/src/api/resources/unstable/resources/news/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { DeleteNewsItemRequest } from "./DeleteNewsItemRequest.js"; -export type { ListLiveNewsfeedItemsRequest } from "./ListLiveNewsfeedItemsRequest.js"; -export type { RetrieveNewsfeedRequest } from "./RetrieveNewsfeedRequest.js"; -export type { RetrieveNewsItemRequest } from "./RetrieveNewsItemRequest.js"; -export type { UpdateNewsItemRequest } from "./UpdateNewsItemRequest.js"; diff --git a/src/api/resources/unstable/resources/news/index.ts b/src/api/resources/unstable/resources/news/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/news/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/news/types/NewsItem.ts b/src/api/resources/unstable/resources/news/types/NewsItem.ts deleted file mode 100644 index a5ecc130..00000000 --- a/src/api/resources/unstable/resources/news/types/NewsItem.ts +++ /dev/null @@ -1,46 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 type of object. */ - type?: "news-item"; - /** 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 const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/resources/news/types/Newsfeed.ts b/src/api/resources/unstable/resources/news/types/Newsfeed.ts deleted file mode 100644 index a42f6306..00000000 --- a/src/api/resources/unstable/resources/news/types/Newsfeed.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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 type of object. */ - type?: "newsfeed"; - /** 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 deleted file mode 100644 index 064483c9..00000000 --- a/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 deleted file mode 100644 index fe7a29c8..00000000 --- a/src/api/resources/unstable/resources/news/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./Newsfeed.js"; -export * from "./NewsfeedAssignment.js"; -export * from "./NewsItem.js"; diff --git a/src/api/resources/unstable/resources/notes/client/Client.ts b/src/api/resources/unstable/resources/notes/client/Client.ts deleted file mode 100644 index 6daafede..00000000 --- a/src/api/resources/unstable/resources/notes/client/Client.ts +++ /dev/null @@ -1,327 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace NotesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Notes - */ -export class NotesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: NotesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of notes that are associated to a company. - * - * @param {Intercom.unstable.ListCompanyNotesRequest} request - * @param {NotesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.notes.listCompanyNotes({ - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * }) - */ - public listCompanyNotes( - request: Intercom.unstable.ListCompanyNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listCompanyNotes(request, requestOptions)); - } - - private async __listCompanyNotes( - request: Intercom.unstable.ListCompanyNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `companies/${core.url.encodePathParam(id)}/notes`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/companies/{id}/notes"); - } - - /** - * You can fetch a list of notes that are associated to a contact. - * - * @param {Intercom.unstable.ListNotesRequest} request - * @param {NotesClient.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?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listNotes(request, requestOptions)); - } - - private async __listNotes( - request: Intercom.unstable.ListNotesRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/notes`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{id}/notes"); - } - - /** - * You can add a note to a single contact. - * - * @param {Intercom.unstable.CreateNoteRequest} request - * @param {NotesClient.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?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createNote(request, requestOptions)); - } - - private async __createNote( - request: Intercom.unstable.CreateNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(id)}/notes`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{id}/notes"); - } - - /** - * You can fetch the details of a single note. - * - * @param {Intercom.unstable.RetrieveNoteRequest} request - * @param {NotesClient.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?: NotesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveNote(request, requestOptions)); - } - - private async __retrieveNote( - request: Intercom.unstable.RetrieveNoteRequest, - requestOptions?: NotesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `notes/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/notes/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/notes/client/index.ts b/src/api/resources/unstable/resources/notes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/notes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts b/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts deleted file mode 100644 index 6802985e..00000000 --- a/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts +++ /dev/null @@ -1,37 +0,0 @@ -// 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/ListCompanyNotesRequest.ts b/src/api/resources/unstable/resources/notes/client/requests/ListCompanyNotesRequest.ts deleted file mode 100644 index 5e97337d..00000000 --- a/src/api/resources/unstable/resources/notes/client/requests/ListCompanyNotesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" - * } - */ -export interface ListCompanyNotesRequest { - /** The unique identifier for the company which is given by Intercom */ - 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 deleted file mode 100644 index 52dfe1b3..00000000 --- a/src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index c6fe4988..00000000 --- a/src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index ed230370..00000000 --- a/src/api/resources/unstable/resources/notes/client/requests/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type { CreateNoteRequest } from "./CreateNoteRequest.js"; -export type { ListCompanyNotesRequest } from "./ListCompanyNotesRequest.js"; -export type { ListNotesRequest } from "./ListNotesRequest.js"; -export type { RetrieveNoteRequest } from "./RetrieveNoteRequest.js"; diff --git a/src/api/resources/unstable/resources/notes/index.ts b/src/api/resources/unstable/resources/notes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/notes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/notes/types/CompanyNote.ts b/src/api/resources/unstable/resources/notes/types/CompanyNote.ts deleted file mode 100644 index d63295c5..00000000 --- a/src/api/resources/unstable/resources/notes/types/CompanyNote.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * Notes allow you to annotate and comment on companies. - */ -export interface CompanyNote { - /** 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 company that the note was created about. */ - company?: CompanyNote.Company; - /** Optional. Represents the Admin that created the note. */ - author?: Intercom.unstable.Admin; - /** The body text of the note. */ - body?: string; -} - -export namespace CompanyNote { - /** - * Represents the company that the note was created about. - */ - export interface Company { - /** String representing the object's type. Always has the value `company`. */ - type?: string; - /** The id of the company. */ - id?: string; - } -} diff --git a/src/api/resources/unstable/resources/notes/types/Note.ts b/src/api/resources/unstable/resources/notes/types/Note.ts deleted file mode 100644 index 571bce49..00000000 --- a/src/api/resources/unstable/resources/notes/types/Note.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 0e6d3d17..00000000 --- a/src/api/resources/unstable/resources/notes/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./CompanyNote.js"; -export * from "./Note.js"; diff --git a/src/api/resources/unstable/resources/segments/client/Client.ts b/src/api/resources/unstable/resources/segments/client/Client.ts deleted file mode 100644 index 64d7c4fb..00000000 --- a/src/api/resources/unstable/resources/segments/client/Client.ts +++ /dev/null @@ -1,177 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace SegmentsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Segments - */ -export class SegmentsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: SegmentsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch a list of all segments. - * - * @param {Intercom.unstable.ListSegmentsRequest} request - * @param {SegmentsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.segments.listSegments({ - * include_count: true - * }) - */ - public listSegments( - request: Intercom.unstable.ListSegmentsRequest = {}, - requestOptions?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSegments(request, requestOptions)); - } - - private async __listSegments( - request: Intercom.unstable.ListSegmentsRequest = {}, - requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { - const { include_count: includeCount } = request; - const _queryParams: Record = {}; - if (includeCount != null) { - _queryParams.include_count = includeCount.toString(); - } - - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "segments", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/segments"); - } - - /** - * You can fetch the details of a single segment. - * - * @param {Intercom.unstable.RetrieveSegmentRequest} request - * @param {SegmentsClient.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?: SegmentsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveSegment(request, requestOptions)); - } - - private async __retrieveSegment( - request: Intercom.unstable.RetrieveSegmentRequest, - requestOptions?: SegmentsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `segments/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/segments/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/segments/client/index.ts b/src/api/resources/unstable/resources/segments/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/segments/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts b/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts deleted file mode 100644 index 7554f000..00000000 --- a/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * include_count: true - * } - */ -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 deleted file mode 100644 index f7877c1e..00000000 --- a/src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 3ef3b577..00000000 --- a/src/api/resources/unstable/resources/segments/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { ListSegmentsRequest } from "./ListSegmentsRequest.js"; -export type { RetrieveSegmentRequest } from "./RetrieveSegmentRequest.js"; diff --git a/src/api/resources/unstable/resources/segments/index.ts b/src/api/resources/unstable/resources/segments/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/segments/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/segments/types/Segment.ts b/src/api/resources/unstable/resources/segments/types/Segment.ts deleted file mode 100644 index 5fbb6b53..00000000 --- a/src/api/resources/unstable/resources/segments/types/Segment.ts +++ /dev/null @@ -1,30 +0,0 @@ -// 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 const PersonType = { - Contact: "contact", - User: "user", - } as const; - export type PersonType = (typeof PersonType)[keyof typeof PersonType]; -} diff --git a/src/api/resources/unstable/resources/segments/types/index.ts b/src/api/resources/unstable/resources/segments/types/index.ts deleted file mode 100644 index a934b01a..00000000 --- a/src/api/resources/unstable/resources/segments/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Segment.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts deleted file mode 100644 index b43baf9e..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts +++ /dev/null @@ -1,272 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace SubscriptionTypesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about subscription types - */ -export class SubscriptionTypesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: SubscriptionTypesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {SubscriptionTypesClient.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?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachSubscriptionTypeToContact(request, requestOptions)); - } - - private async __attachSubscriptionTypeToContact( - request: Intercom.unstable.AttachSubscriptionTypeToContactRequest, - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/contacts/{contact_id}/subscriptions", - ); - } - - /** - * 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 {SubscriptionTypesClient.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?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachSubscriptionTypeToContact(request, requestOptions)); - } - - private async __detachSubscriptionTypeToContact( - request: Intercom.unstable.DetachSubscriptionTypeToContactRequest, - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/subscriptions/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/subscriptions/{id}", - ); - } - - /** - * You can list all subscription types. A list of subscription type objects will be returned. - * - * @param {SubscriptionTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.subscriptionTypes.listSubscriptionTypes() - */ - public listSubscriptionTypes( - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listSubscriptionTypes(requestOptions)); - } - - private async __listSubscriptionTypes( - requestOptions?: SubscriptionTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "subscription_types", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/subscription_types"); - } -} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts deleted file mode 100644 index 18911f33..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 deleted file mode 100644 index 156af2ee..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index ce062982..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { AttachSubscriptionTypeToContactRequest } from "./AttachSubscriptionTypeToContactRequest.js"; -export type { DetachSubscriptionTypeToContactRequest } from "./DetachSubscriptionTypeToContactRequest.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts b/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts deleted file mode 100644 index 3867aa94..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const State = { - Live: "live", - Draft: "draft", - Archived: "archived", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** Describes the type of consent. */ - export const ConsentType = { - OptOut: "opt_out", - OptIn: "opt_in", - } as const; - export type ConsentType = (typeof ConsentType)[keyof typeof ConsentType]; - export type ContentTypes = ContentTypes.Item[]; - - export namespace ContentTypes { - export const Item = { - Email: "email", - SmsMessage: "sms_message", - } as const; - export type Item = (typeof Item)[keyof typeof Item]; - } -} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts deleted file mode 100644 index b6a27359..00000000 --- a/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./SubscriptionType.js"; diff --git a/src/api/resources/unstable/resources/switch/client/Client.ts b/src/api/resources/unstable/resources/switch/client/Client.ts deleted file mode 100644 index 0c95ab0e..00000000 --- a/src/api/resources/unstable/resources/switch/client/Client.ts +++ /dev/null @@ -1,115 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace SwitchClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about Switch - */ -export class SwitchClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: SwitchClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {SwitchClient.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?: SwitchClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createPhoneSwitch(request, requestOptions)); - } - - private async __createPhoneSwitch( - request?: unknown, - requestOptions?: SwitchClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "phone_call_redirects", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/phone_call_redirects"); - } -} diff --git a/src/api/resources/unstable/resources/switch/client/index.ts b/src/api/resources/unstable/resources/switch/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/unstable/resources/switch/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/unstable/resources/switch/index.ts b/src/api/resources/unstable/resources/switch/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/switch/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/tags/client/Client.ts b/src/api/resources/unstable/resources/tags/client/Client.ts deleted file mode 100644 index 681b40df..00000000 --- a/src/api/resources/unstable/resources/tags/client/Client.ts +++ /dev/null @@ -1,850 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TagsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about tags - */ -export class TagsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TagsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachTagToContact(request, requestOptions)); - } - - private async __attachTagToContact( - request: Intercom.unstable.AttachTagToContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts/{contact_id}/tags"); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachTagFromContact(request, requestOptions)); - } - - private async __detachTagFromContact( - request: Intercom.unstable.DetachTagFromContactRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { contact_id: contactId, id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${core.url.encodePathParam(contactId)}/tags/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/contacts/{contact_id}/tags/{id}", - ); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachTagToConversation(request, requestOptions)); - } - - private async __attachTagToConversation( - request: Intercom.unstable.AttachTagToConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/conversations/{conversation_id}/tags", - ); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachTagFromConversation(request, requestOptions)); - } - - private async __detachTagFromConversation( - request: Intercom.unstable.DetachTagFromConversationRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { conversation_id: conversationId, id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `conversations/${core.url.encodePathParam(conversationId)}/tags/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/conversations/{conversation_id}/tags/{id}", - ); - } - - /** - * You can fetch a list of all tags for a given workspace. - * - * - * @param {TagsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.tags.listTags() - */ - public listTags(requestOptions?: TagsClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTags(requestOptions)); - } - - private async __listTags( - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tags", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tags"); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createTag(request, requestOptions)); - } - - private async __createTag( - request: Intercom.unstable.CreateTagRequestBody, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tags", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tags"); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__findTag(request, requestOptions)); - } - - private async __findTag( - request: Intercom.unstable.FindTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tags/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tags/{id}"); - } - - /** - * You can delete the details of tags that are on the workspace by passing in the id. - * - * @param {Intercom.unstable.DeleteTagRequest} request - * @param {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteTag(request, requestOptions)); - } - - private async __deleteTag( - request: Intercom.unstable.DeleteTagRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tags/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/tags/{id}"); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__attachTagToTicket(request, requestOptions)); - } - - private async __attachTagToTicket( - request: Intercom.unstable.AttachTagToTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}/tags`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/{ticket_id}/tags"); - } - - /** - * 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 {TagsClient.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?: TagsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__detachTagFromTicket(request, requestOptions)); - } - - private async __detachTagFromTicket( - request: Intercom.unstable.DetachTagFromTicketRequest, - requestOptions?: TagsClient.RequestOptions, - ): Promise> { - const { ticket_id: ticketId, id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(ticketId)}/tags/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/tickets/{ticket_id}/tags/{id}", - ); - } -} diff --git a/src/api/resources/unstable/resources/tags/client/index.ts b/src/api/resources/unstable/resources/tags/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/tags/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts deleted file mode 100644 index 94218c40..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index c6084c34..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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 deleted file mode 100644 index 4082336b..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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 deleted file mode 100644 index 1c226490..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 6737ddff..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 9cc3452f..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 deleted file mode 100644 index 9c6e58ac..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 deleted file mode 100644 index f3f35724..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 5e52c0b2..00000000 --- a/src/api/resources/unstable/resources/tags/client/requests/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type { AttachTagToContactRequest } from "./AttachTagToContactRequest.js"; -export type { AttachTagToConversationRequest } from "./AttachTagToConversationRequest.js"; -export type { AttachTagToTicketRequest } from "./AttachTagToTicketRequest.js"; -export type { DeleteTagRequest } from "./DeleteTagRequest.js"; -export type { DetachTagFromContactRequest } from "./DetachTagFromContactRequest.js"; -export type { DetachTagFromConversationRequest } from "./DetachTagFromConversationRequest.js"; -export type { DetachTagFromTicketRequest } from "./DetachTagFromTicketRequest.js"; -export type { FindTagRequest } from "./FindTagRequest.js"; diff --git a/src/api/resources/unstable/resources/tags/index.ts b/src/api/resources/unstable/resources/tags/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/tags/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts b/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts deleted file mode 100644 index 9f3ab1dc..00000000 --- a/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index f62cbefb..00000000 --- a/src/api/resources/unstable/resources/tags/types/Tag.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 8e8b815d..00000000 --- a/src/api/resources/unstable/resources/tags/types/TagBasic.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index f1b106ee..00000000 --- a/src/api/resources/unstable/resources/tags/types/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./CreateTagRequestBody.js"; -export * from "./Tag.js"; -export * from "./TagBasic.js"; diff --git a/src/api/resources/unstable/resources/teams/client/Client.ts b/src/api/resources/unstable/resources/teams/client/Client.ts deleted file mode 100644 index c83adaf9..00000000 --- a/src/api/resources/unstable/resources/teams/client/Client.ts +++ /dev/null @@ -1,166 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TeamsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Teams - */ -export class TeamsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TeamsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * This will return a list of team objects for the App. - * - * @param {TeamsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.teams.listTeams() - */ - public listTeams( - requestOptions?: TeamsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTeams(requestOptions)); - } - - private async __listTeams( - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "teams", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams"); - } - - /** - * 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 {TeamsClient.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?: TeamsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveTeam(request, requestOptions)); - } - - private async __retrieveTeam( - request: Intercom.unstable.RetrieveTeamRequest, - requestOptions?: TeamsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `teams/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/teams/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/teams/client/index.ts b/src/api/resources/unstable/resources/teams/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/teams/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts b/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts deleted file mode 100644 index fd825fee..00000000 --- a/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 6497a22a..00000000 --- a/src/api/resources/unstable/resources/teams/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { RetrieveTeamRequest } from "./RetrieveTeamRequest.js"; diff --git a/src/api/resources/unstable/resources/teams/index.ts b/src/api/resources/unstable/resources/teams/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/teams/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/teams/types/Team.ts b/src/api/resources/unstable/resources/teams/types/Team.ts deleted file mode 100644 index 412cc0d0..00000000 --- a/src/api/resources/unstable/resources/teams/types/Team.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index bc100e99..00000000 --- a/src/api/resources/unstable/resources/teams/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Team.js"; diff --git a/src/api/resources/unstable/resources/ticketStates/client/Client.ts b/src/api/resources/unstable/resources/ticketStates/client/Client.ts deleted file mode 100644 index 84960f00..00000000 --- a/src/api/resources/unstable/resources/ticketStates/client/Client.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TicketStatesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your ticket states - */ -export class TicketStatesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketStatesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can get a list of all ticket states for a workspace. - * - * @param {TicketStatesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.ticketStates.listTicketStates() - */ - public listTicketStates( - requestOptions?: TicketStatesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTicketStates(requestOptions)); - } - - private async __listTicketStates( - requestOptions?: TicketStatesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_states", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ticket_states"); - } -} diff --git a/src/api/resources/unstable/resources/ticketStates/client/index.ts b/src/api/resources/unstable/resources/ticketStates/client/index.ts deleted file mode 100644 index cb0ff5c3..00000000 --- a/src/api/resources/unstable/resources/ticketStates/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/api/resources/unstable/resources/ticketStates/index.ts b/src/api/resources/unstable/resources/ticketStates/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/ticketStates/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts deleted file mode 100644 index fe5a1095..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts +++ /dev/null @@ -1,197 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TicketTypeAttributesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your ticket type attributes - */ -export class TicketTypeAttributesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketTypeAttributesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can create a new attribute for a ticket type. - * - * @param {Intercom.unstable.CreateTicketTypeAttributeRequest} request - * @param {TicketTypeAttributesClient.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?: TicketTypeAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createTicketTypeAttribute(request, requestOptions)); - } - - private async __createTicketTypeAttribute( - request: Intercom.unstable.CreateTicketTypeAttributeRequest, - requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}/attributes`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/ticket_types/{ticket_type_id}/attributes", - ); - } - - /** - * You can update an existing attribute for a ticket type. - * - * @param {Intercom.unstable.UpdateTicketTypeAttributeRequest} request - * @param {TicketTypeAttributesClient.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?: TicketTypeAttributesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateTicketTypeAttribute(request, requestOptions)); - } - - private async __updateTicketTypeAttribute( - request: Intercom.unstable.UpdateTicketTypeAttributeRequest, - requestOptions?: TicketTypeAttributesClient.RequestOptions, - ): Promise> { - const { ticket_type_id: ticketTypeId, id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(ticketTypeId)}/attributes/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PUT", - "/ticket_types/{ticket_type_id}/attributes/{id}", - ); - } -} diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts deleted file mode 100644 index 6dbf0ac2..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts +++ /dev/null @@ -1,50 +0,0 @@ -// 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 const DataType = { - String: "string", - List: "list", - Integer: "integer", - Decimal: "decimal", - Boolean: "boolean", - Datetime: "datetime", - Files: "files", - } as const; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts deleted file mode 100644 index c56bbb7b..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts +++ /dev/null @@ -1,36 +0,0 @@ -// 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 deleted file mode 100644 index 2a2ffb63..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { CreateTicketTypeAttributeRequest } from "./CreateTicketTypeAttributeRequest.js"; -export type { UpdateTicketTypeAttributeRequest } from "./UpdateTicketTypeAttributeRequest.js"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypes/client/Client.ts b/src/api/resources/unstable/resources/ticketTypes/client/Client.ts deleted file mode 100644 index 1d1adfed..00000000 --- a/src/api/resources/unstable/resources/ticketTypes/client/Client.ts +++ /dev/null @@ -1,246 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TicketTypesClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your ticket types - */ -export class TicketTypesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketTypesClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can get a list of all ticket types for a workspace. - * - * @param {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.ticketTypes.listTicketTypes() - */ - public listTicketTypes( - requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__listTicketTypes(requestOptions)); - } - - private async __listTicketTypes( - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_types", - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ticket_types"); - } - - /** - * 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 {TicketTypesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.UnauthorizedError} - * - * @example - * await client.unstable.ticketTypes.createTicketType({ - * "key": "value" - * }) - */ - public createTicketType( - request?: unknown, - requestOptions?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__createTicketType(request, requestOptions)); - } - - private async __createTicketType( - request?: unknown, - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "ticket_types", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/ticket_types"); - } - - /** - * You can fetch the details of a single ticket type. - * - * @param {Intercom.unstable.GetTicketTypeRequest} request - * @param {TicketTypesClient.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?: TicketTypesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getTicketType(request, requestOptions)); - } - - private async __getTicketType( - request: Intercom.unstable.GetTicketTypeRequest, - requestOptions?: TicketTypesClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `ticket_types/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/ticket_types/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/ticketTypes/client/index.ts b/src/api/resources/unstable/resources/ticketTypes/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/ticketTypes/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts b/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts deleted file mode 100644 index 542c28d9..00000000 --- a/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 0ece78d7..00000000 --- a/src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { GetTicketTypeRequest } from "./GetTicketTypeRequest.js"; diff --git a/src/api/resources/unstable/resources/ticketTypes/index.ts b/src/api/resources/unstable/resources/ticketTypes/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/ticketTypes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/tickets/client/Client.ts b/src/api/resources/unstable/resources/tickets/client/Client.ts deleted file mode 100644 index 4c28d71b..00000000 --- a/src/api/resources/unstable/resources/tickets/client/Client.ts +++ /dev/null @@ -1,627 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace TicketsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your tickets - */ -export class TicketsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: TicketsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(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 {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__replyTicket(request, requestOptions)); - } - - private async __replyTicket( - request: Intercom.unstable.ReplyTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { id, body: _body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(id)}/reply`, - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/{id}/reply"); - } - - /** - * 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 {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__enqueueCreateTicket(request, requestOptions)); - } - - private async __enqueueCreateTicket( - request: Intercom.unstable.EnqueueCreateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets/enqueue", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/enqueue"); - } - - /** - * You can fetch the details of a single ticket. - * - * @param {Intercom.unstable.GetTicketRequest} request - * @param {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__getTicket(request, requestOptions)); - } - - private async __getTicket( - request: Intercom.unstable.GetTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/tickets/{id}"); - } - - /** - * You can update a ticket. - * - * @param {Intercom.unstable.UpdateTicketRequest} request - * @param {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateTicket(request, requestOptions)); - } - - private async __updateTicket( - request: Intercom.unstable.UpdateTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { id, ..._body } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(id)}`, - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: _body, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/tickets/{id}"); - } - - /** - * You can delete a ticket using the Intercom provided ID. - * - * @param {Intercom.unstable.DeleteTicketRequest} request - * @param {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__deleteTicket(request, requestOptions)); - } - - private async __deleteTicket( - request: Intercom.unstable.DeleteTicketRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `tickets/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/tickets/{id}"); - } - - /** - * 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) | - * | title | String | - * | 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 | - * - * {% admonition type="info" name="Searching by Category" %} - * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: - * * For **Customer** category tickets, use the term `request`. - * * For **Back-office** category tickets, use the term `task`. - * * For **Tracker** category tickets, use the term `tracker`. - * {% /admonition %} - * - * ### Accepted Operators - * - * {% admonition type="info" name="Searching based on `created_at`" %} - * 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 {TicketsClient.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?: TicketsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__searchTickets(request, requestOptions)); - } - - private async __searchTickets( - request: Intercom.unstable.SearchRequest, - requestOptions?: TicketsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets/search", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/tickets/search"); - } -} diff --git a/src/api/resources/unstable/resources/tickets/client/index.ts b/src/api/resources/unstable/resources/tickets/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/tickets/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts deleted file mode 100644 index 8ea2c5e7..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 74d72736..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index c48305e2..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 1e53f5d6..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../../index.js"; - -/** - * @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 deleted file mode 100644 index 63d68d08..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts +++ /dev/null @@ -1,67 +0,0 @@ -// 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 deleted file mode 100644 index 8f0e8032..00000000 --- a/src/api/resources/unstable/resources/tickets/client/requests/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { DeleteTicketRequest } from "./DeleteTicketRequest.js"; -export type { EnqueueCreateTicketRequest } from "./EnqueueCreateTicketRequest.js"; -export type { GetTicketRequest } from "./GetTicketRequest.js"; -export type { ReplyTicketRequest } from "./ReplyTicketRequest.js"; -export type { UpdateTicketRequest } from "./UpdateTicketRequest.js"; diff --git a/src/api/resources/unstable/resources/tickets/index.ts b/src/api/resources/unstable/resources/tickets/index.ts deleted file mode 100644 index d9adb1af..00000000 --- a/src/api/resources/unstable/resources/tickets/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./client/index.js"; -export * from "./types/index.js"; diff --git a/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts b/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts deleted file mode 100644 index cdad7f2d..00000000 --- a/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index cc0d3384..00000000 --- a/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -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 deleted file mode 100644 index 1da56448..00000000 --- a/src/api/resources/unstable/resources/tickets/types/Ticket.ts +++ /dev/null @@ -1,47 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts b/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts deleted file mode 100644 index f85afa9f..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 deleted file mode 100644 index 6ab9ce04..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketPart.ts +++ /dev/null @@ -1,109 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const PreviousTicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type PreviousTicketState = (typeof PreviousTicketState)[keyof typeof PreviousTicketState]; - /** The state of the ticket. */ - export const TicketState = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type TicketState = (typeof TicketState)[keyof typeof TicketState]; - - /** - * 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 deleted file mode 100644 index beef89c7..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketState.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts b/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts deleted file mode 100644 index 1281034c..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts +++ /dev/null @@ -1,44 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const Category = { - Submitted: "submitted", - InProgress: "in_progress", - WaitingOnCustomer: "waiting_on_customer", - Resolved: "resolved", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * 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 deleted file mode 100644 index bdb7bae4..00000000 --- a/src/api/resources/unstable/resources/tickets/types/TicketType.ts +++ /dev/null @@ -1,52 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../../../index.js"; - -/** - * 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 const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; - - /** - * 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 deleted file mode 100644 index 5cad94df..00000000 --- a/src/api/resources/unstable/resources/tickets/types/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./DeleteTicketResponse.js"; -export * from "./ReplyTicketRequestBody.js"; -export * from "./Ticket.js"; -export * from "./TicketContacts.js"; -export * from "./TicketPart.js"; -export * from "./TicketState.js"; -export * from "./TicketStateDetailed.js"; -export * from "./TicketType.js"; diff --git a/src/api/resources/unstable/resources/visitors/client/Client.ts b/src/api/resources/unstable/resources/visitors/client/Client.ts deleted file mode 100644 index 600ffecf..00000000 --- a/src/api/resources/unstable/resources/visitors/client/Client.ts +++ /dev/null @@ -1,279 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace VisitorsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Visitors - */ -export class VisitorsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: VisitorsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch the details of a single visitor. - * - * @param {Intercom.unstable.RetrieveVisitorWithUserIdRequest} request - * @param {VisitorsClient.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?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__retrieveVisitorWithUserId(request, requestOptions)); - } - - private async __retrieveVisitorWithUserId( - request: Intercom.unstable.RetrieveVisitorWithUserIdRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const { user_id: userId } = request; - const _queryParams: Record = {}; - _queryParams.user_id = userId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/visitors"); - } - - /** - * 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 {VisitorsClient.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?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__updateVisitor(request, requestOptions)); - } - - private async __updateVisitor( - request?: Intercom.UpdateVisitorRequestOne, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors", - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/visitors"); - } - - /** - * 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 {VisitorsClient.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?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__convertVisitor(request, requestOptions)); - } - - private async __convertVisitor( - request: Intercom.unstable.ConvertVisitorRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors/convert", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/visitors/convert"); - } -} diff --git a/src/api/resources/unstable/resources/visitors/client/index.ts b/src/api/resources/unstable/resources/visitors/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/visitors/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts b/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts deleted file mode 100644 index 0dceb82c..00000000 --- a/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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 deleted file mode 100644 index cd10d234..00000000 --- a/src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index a1b1278e..00000000 --- a/src/api/resources/unstable/resources/visitors/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { ConvertVisitorRequest } from "./ConvertVisitorRequest.js"; -export type { RetrieveVisitorWithUserIdRequest } from "./RetrieveVisitorWithUserIdRequest.js"; diff --git a/src/api/resources/unstable/resources/visitors/index.ts b/src/api/resources/unstable/resources/visitors/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/visitors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/resources/workflows/client/Client.ts b/src/api/resources/unstable/resources/workflows/client/Client.ts deleted file mode 100644 index 9e14a53a..00000000 --- a/src/api/resources/unstable/resources/workflows/client/Client.ts +++ /dev/null @@ -1,107 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; -import * as core from "../../../../../../core/index.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Intercom from "../../../../../index.js"; - -export declare namespace WorkflowsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Export workflow configurations from your workspace. - */ -export class WorkflowsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: WorkflowsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Export a workflow configuration by its ID. This endpoint returns the complete workflow definition including its steps, targeting rules, and attributes. - * - * This endpoint is designed for EU Data Act compliance, allowing customers to export their workflow configurations. - * - * {% admonition type="warning" name="Unstable API" %} - * This API is currently in the Unstable version. Its behavior may change in future releases. - * {% /admonition %} - * - * @param {Intercom.unstable.ExportWorkflowRequest} request - * @param {WorkflowsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.unstable.ForbiddenError} - * @throws {@link Intercom.unstable.NotFoundError} - * - * @example - * await client.unstable.workflows.exportWorkflow({ - * id: "12345" - * }) - */ - public exportWorkflow( - request: Intercom.unstable.ExportWorkflowRequest, - requestOptions?: WorkflowsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__exportWorkflow(request, requestOptions)); - } - - private async __exportWorkflow( - request: Intercom.unstable.ExportWorkflowRequest, - requestOptions?: WorkflowsClient.RequestOptions, - ): Promise> { - const { id } = request; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `export/workflows/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryParameters: requestOptions?.queryParams, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.unstable.WorkflowExport, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - 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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/export/workflows/{id}"); - } -} diff --git a/src/api/resources/unstable/resources/workflows/client/index.ts b/src/api/resources/unstable/resources/workflows/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/unstable/resources/workflows/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/unstable/resources/workflows/client/requests/ExportWorkflowRequest.ts b/src/api/resources/unstable/resources/workflows/client/requests/ExportWorkflowRequest.ts deleted file mode 100644 index f8d7dd1d..00000000 --- a/src/api/resources/unstable/resources/workflows/client/requests/ExportWorkflowRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * id: "12345" - * } - */ -export interface ExportWorkflowRequest { - /** The unique identifier for the workflow */ - id: string; -} diff --git a/src/api/resources/unstable/resources/workflows/client/requests/index.ts b/src/api/resources/unstable/resources/workflows/client/requests/index.ts deleted file mode 100644 index b9acc294..00000000 --- a/src/api/resources/unstable/resources/workflows/client/requests/index.ts +++ /dev/null @@ -1 +0,0 @@ -export type { ExportWorkflowRequest } from "./ExportWorkflowRequest.js"; diff --git a/src/api/resources/unstable/resources/workflows/index.ts b/src/api/resources/unstable/resources/workflows/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/unstable/resources/workflows/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/resources/unstable/types/ActivityLog.ts b/src/api/resources/unstable/types/ActivityLog.ts deleted file mode 100644 index e510cac9..00000000 --- a/src/api/resources/unstable/types/ActivityLog.ts +++ /dev/null @@ -1,107 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const ActivityType = { - AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", - AdminTicketAssignmentLimitChange: "admin_ticket_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; - export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; -} diff --git a/src/api/resources/unstable/types/ActivityLogList.ts b/src/api/resources/unstable/types/ActivityLogList.ts deleted file mode 100644 index f570390b..00000000 --- a/src/api/resources/unstable/types/ActivityLogList.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index cbd7324e..00000000 --- a/src/api/resources/unstable/types/ActivityLogMetadata.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 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; - /** The conversation assignment limit value for an admin. */ - conversation_assignment_limit?: number; - /** The ticket assignment limit value for an admin. */ - ticket_assignment_limit?: number; -} diff --git a/src/api/resources/unstable/types/AddressableList.ts b/src/api/resources/unstable/types/AddressableList.ts deleted file mode 100644 index cbda5a63..00000000 --- a/src/api/resources/unstable/types/AddressableList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 01507d8d..00000000 --- a/src/api/resources/unstable/types/AdminList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 1127dadf..00000000 --- a/src/api/resources/unstable/types/AdminPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 deleted file mode 100644 index cf90c85b..00000000 --- a/src/api/resources/unstable/types/AdminReplyConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/resources/unstable/types/AdminReplyTicketRequest.ts b/src/api/resources/unstable/types/AdminReplyTicketRequest.ts deleted file mode 100644 index 3e2ac1ed..00000000 --- a/src/api/resources/unstable/types/AdminReplyTicketRequest.ts +++ /dev/null @@ -1,38 +0,0 @@ -// 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 const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; - 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 deleted file mode 100644 index 37c0c32c..00000000 --- a/src/api/resources/unstable/types/AdminWithApp.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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/AiCallResponse.ts b/src/api/resources/unstable/types/AiCallResponse.ts deleted file mode 100644 index 6f90c177..00000000 --- a/src/api/resources/unstable/types/AiCallResponse.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response containing information about a Fin Voice call - */ -export interface AiCallResponse { - /** The unique identifier for the external reference */ - id?: number; - /** The workspace identifier */ - app_id?: number; - /** Phone number in E.164 format for the call */ - user_phone_number?: string; - /** Status of the call. Can be "registered", "in-progress", or a resolution state */ - status?: string; - /** The Intercom call identifier, if the call has been matched */ - intercom_call_id?: string; - /** The external call identifier from the call provider */ - external_call_id?: string; - /** The Intercom conversation identifier, if a conversation has been created */ - intercom_conversation_id?: string; - /** Array of transcript entries for the call */ - call_transcript?: Record[]; - /** Summary of the call conversation, truncated to 256 characters. Empty string if no summary available. */ - call_summary?: string; - /** Array of intent classifications for the call */ - intent?: Record[]; -} diff --git a/src/api/resources/unstable/types/App.ts b/src/api/resources/unstable/types/App.ts deleted file mode 100644 index 67ce2d3c..00000000 --- a/src/api/resources/unstable/types/App.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index bccb5af5..00000000 --- a/src/api/resources/unstable/types/ArticleContent.ts +++ /dev/null @@ -1,34 +0,0 @@ -// 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?: "article_content"; - /** 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/ArticleList.ts b/src/api/resources/unstable/types/ArticleList.ts deleted file mode 100644 index 67d409ef..00000000 --- a/src/api/resources/unstable/types/ArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 16f14f48..00000000 --- a/src/api/resources/unstable/types/ArticleStatistics.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index 2e625936..00000000 --- a/src/api/resources/unstable/types/ArticleTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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?: "article_translated_content"; - /** 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 deleted file mode 100644 index 0e2e8ba8..00000000 --- a/src/api/resources/unstable/types/AssignConversationRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 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 const Type = { - Admin: "admin", - Team: "team", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/AwayStatusReason.ts b/src/api/resources/unstable/types/AwayStatusReason.ts deleted file mode 100644 index 01eaf720..00000000 --- a/src/api/resources/unstable/types/AwayStatusReason.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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/CallList.ts b/src/api/resources/unstable/types/CallList.ts deleted file mode 100644 index bd332337..00000000 --- a/src/api/resources/unstable/types/CallList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A paginated list of calls. - */ -export interface CallList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of calls. */ - data?: Intercom.unstable.Call[]; - /** Total number of items available. */ - total_count?: number; - pages?: Intercom.unstable.CursorPages; -} diff --git a/src/api/resources/unstable/types/CloseConversationRequest.ts b/src/api/resources/unstable/types/CloseConversationRequest.ts deleted file mode 100644 index 0c75f0c3..00000000 --- a/src/api/resources/unstable/types/CloseConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 455ae28a..00000000 --- a/src/api/resources/unstable/types/CollectionList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index d23643b4..00000000 --- a/src/api/resources/unstable/types/CompanyAttachedContacts.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 73ace745..00000000 --- a/src/api/resources/unstable/types/CompanyAttachedSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 29d3a559..00000000 --- a/src/api/resources/unstable/types/CompanyData.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 670df0a5..00000000 --- a/src/api/resources/unstable/types/CompanyList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 4f876c99..00000000 --- a/src/api/resources/unstable/types/CompanyScroll.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index b99dc919..00000000 --- a/src/api/resources/unstable/types/ContactArchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index c9afae62..00000000 --- a/src/api/resources/unstable/types/ContactAttachedCompanies.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 0d31658f..00000000 --- a/src/api/resources/unstable/types/ContactBlocked.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index c78c8889..00000000 --- a/src/api/resources/unstable/types/ContactCompanies.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index c5a47283..00000000 --- a/src/api/resources/unstable/types/ContactDeleted.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 5ef1b342..00000000 --- a/src/api/resources/unstable/types/ContactList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 73f32530..00000000 --- a/src/api/resources/unstable/types/ContactLocation.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 88338f22..00000000 --- a/src/api/resources/unstable/types/ContactNotes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 6ff6080e..00000000 --- a/src/api/resources/unstable/types/ContactReference.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index e6ebd102..00000000 --- a/src/api/resources/unstable/types/ContactReplyBaseRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index eb27b919..00000000 --- a/src/api/resources/unstable/types/ContactReplyConversationRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 31f73734..00000000 --- a/src/api/resources/unstable/types/ContactReplyEmailRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index edd5a8fd..00000000 --- a/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index bad5a71c..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 70a2d6e2..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 523c59ef..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 51ec38dc..00000000 --- a/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 6870f212..00000000 --- a/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 370cfde9..00000000 --- a/src/api/resources/unstable/types/ContactSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index dd46662b..00000000 --- a/src/api/resources/unstable/types/ContactSocialProfiles.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index b478bc44..00000000 --- a/src/api/resources/unstable/types/ContactSubscriptionTypes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 2ed6d4e7..00000000 --- a/src/api/resources/unstable/types/ContactTags.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index e5b151a1..00000000 --- a/src/api/resources/unstable/types/ContactUnarchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index aee5ab31..00000000 --- a/src/api/resources/unstable/types/ContentSourcesList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index f1a0b3e5..00000000 --- a/src/api/resources/unstable/types/ConversationAttachmentFiles.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 997b2ea3..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 { - /** Current value of the CDA updated */ - name?: string; - /** Previous value of the CDA */ - previous?: string; - } -} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts deleted file mode 100644 index c0f19e67..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByUser.ts +++ /dev/null @@ -1,23 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about Custom Data Attributes (CDAs) that were modified by a user for conversation part type conversation_attribute_updated_by_user. - */ -export interface ConversationAttributeUpdatedByUser { - attribute?: ConversationAttributeUpdatedByUser.Attribute; - value?: ConversationAttributeUpdatedByUser.Value; -} - -export namespace ConversationAttributeUpdatedByUser { - export interface Attribute { - /** Name of the CDA updated */ - name?: string; - } - - export interface Value { - /** Current value of the CDA updated */ - name?: string; - /** Previous value of the CDA (null for older events) */ - previous?: string; - } -} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts deleted file mode 100644 index e9e75f32..00000000 --- a/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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 deleted file mode 100644 index eb49d28f..00000000 --- a/src/api/resources/unstable/types/ConversationContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index e61823b9..00000000 --- a/src/api/resources/unstable/types/ConversationDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 2085bd1e..00000000 --- a/src/api/resources/unstable/types/ConversationFirstContactReply.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 9a0a768e..00000000 --- a/src/api/resources/unstable/types/ConversationList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 0d55a965..00000000 --- a/src/api/resources/unstable/types/ConversationPart.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/ConversationPartAuthor.ts b/src/api/resources/unstable/types/ConversationPartAuthor.ts deleted file mode 100644 index 3a17d751..00000000 --- a/src/api/resources/unstable/types/ConversationPartAuthor.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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 deleted file mode 100644 index 73de6365..00000000 --- a/src/api/resources/unstable/types/ConversationPartMetadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index a1e3f943..00000000 --- a/src/api/resources/unstable/types/ConversationParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 1edf63c5..00000000 --- a/src/api/resources/unstable/types/ConversationRating.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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; - /** The time the rating was last updated. */ - updated_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 deleted file mode 100644 index 8c503679..00000000 --- a/src/api/resources/unstable/types/ConversationResponseTime.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/ConversationSlaAppliedByRule.ts b/src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts deleted file mode 100644 index 8340e44f..00000000 --- a/src/api/resources/unstable/types/ConversationSlaAppliedByRule.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about SLA applied by modern Operator workflows for conversation part type conversation_sla_applied_by_rule. - */ -export interface ConversationSlaAppliedByRule { - /** Name of the SLA that was applied */ - sla_name?: string; - /** Target times configured for the SLA (in seconds) */ - sla_definition?: ConversationSlaAppliedByRule.SlaDefinition; -} - -export namespace ConversationSlaAppliedByRule { - /** - * Target times configured for the SLA (in seconds) - */ - export interface SlaDefinition { - /** First response time target in seconds */ - first_reply_time?: number; - /** Next reply time target in seconds */ - next_reply_time?: number; - /** Resolution time target in seconds */ - resolution_time?: number; - /** Time to close target in seconds */ - time_to_close?: number; - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts b/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts deleted file mode 100644 index 29b5464d..00000000 --- a/src/api/resources/unstable/types/ConversationSlaAppliedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about SLA applied by legacy Inbox Rules for conversation part type conversation_sla_applied_by_workflow. - */ -export interface ConversationSlaAppliedByWorkflow { - /** Name of the SLA that was applied */ - sla_name?: string; - /** Target times configured for the SLA (in seconds) */ - sla_definition?: ConversationSlaAppliedByWorkflow.SlaDefinition; -} - -export namespace ConversationSlaAppliedByWorkflow { - /** - * Target times configured for the SLA (in seconds) - */ - export interface SlaDefinition { - /** First response time target in seconds */ - first_reply_time?: number; - /** Next reply time target in seconds */ - next_reply_time?: number; - /** Resolution time target in seconds */ - resolution_time?: number; - /** Time to close target in seconds */ - time_to_close?: number; - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaPaused.ts b/src/api/resources/unstable/types/ConversationSlaPaused.ts deleted file mode 100644 index eb842828..00000000 --- a/src/api/resources/unstable/types/ConversationSlaPaused.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains SLA status at the moment of pausing for conversation part type conversation_sla_paused. - */ -export interface ConversationSlaPaused { - /** Name of the SLA being paused */ - sla_name?: string; - /** Overall SLA status at pause time */ - current_sla_status?: ConversationSlaPaused.CurrentSlaStatus; - /** Status of all SLA targets at pause time */ - sla_states?: Record; -} - -export namespace ConversationSlaPaused { - /** Overall SLA status at pause time */ - export const CurrentSlaStatus = { - Active: "active", - Hit: "hit", - Missed: "missed", - Canceled: "canceled", - } as const; - export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; - - export namespace SlaStates { - export interface Value { - /** Status of this specific target (always paused) */ - status?: "paused"; - /** Time remaining when paused */ - seconds_remaining?: number; - } - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaRemoved.ts b/src/api/resources/unstable/types/ConversationSlaRemoved.ts deleted file mode 100644 index c0007356..00000000 --- a/src/api/resources/unstable/types/ConversationSlaRemoved.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains basic SLA information when removed for conversation part type conversation_sla_removed. - */ -export interface ConversationSlaRemoved { - /** Name of the SLA that was removed */ - sla_name?: string; -} diff --git a/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts b/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts deleted file mode 100644 index bec5f996..00000000 --- a/src/api/resources/unstable/types/ConversationSlaTargetMissed.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains complete status of all SLA targets when a breach occurs for conversation part type conversation_sla_target_missed. - */ -export interface ConversationSlaTargetMissed { - /** Name of the SLA */ - sla_name?: string; - /** Which specific target was missed */ - sla_target_type?: ConversationSlaTargetMissed.SlaTargetType; - /** Overall SLA status */ - current_sla_status?: ConversationSlaTargetMissed.CurrentSlaStatus; - /** Status of all SLA targets at the time of breach */ - sla_states?: Record; -} - -export namespace ConversationSlaTargetMissed { - /** Which specific target was missed */ - export const SlaTargetType = { - FirstReplyTime: "first_reply_time", - NextReplyTime: "next_reply_time", - ResolutionTime: "resolution_time", - TimeToClose: "time_to_close", - } as const; - export type SlaTargetType = (typeof SlaTargetType)[keyof typeof SlaTargetType]; - /** Overall SLA status */ - export const CurrentSlaStatus = { - Hit: "hit", - Missed: "missed", - Active: "active", - Paused: "paused", - Canceled: "canceled", - } as const; - export type CurrentSlaStatus = (typeof CurrentSlaStatus)[keyof typeof CurrentSlaStatus]; - - export namespace SlaStates { - export interface Value { - /** Status of this specific target */ - status?: Value.Status; - /** Time remaining for active/paused targets (null for hit/missed) */ - seconds_remaining?: number; - } - - export namespace Value { - /** Status of this specific target */ - export const Status = { - Hit: "hit", - Missed: "missed", - Active: "active", - Paused: "paused", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/resources/unstable/types/ConversationSlaUnpaused.ts b/src/api/resources/unstable/types/ConversationSlaUnpaused.ts deleted file mode 100644 index e7045d0f..00000000 --- a/src/api/resources/unstable/types/ConversationSlaUnpaused.ts +++ /dev/null @@ -1,9 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains basic SLA information when unpaused for conversation part type conversation_sla_unpaused. - */ -export interface ConversationSlaUnpaused { - /** Name of the SLA being unpaused */ - sla_name?: string; -} diff --git a/src/api/resources/unstable/types/ConversationSource.ts b/src/api/resources/unstable/types/ConversationSource.ts deleted file mode 100644 index 3987bf3f..00000000 --- a/src/api/resources/unstable/types/ConversationSource.ts +++ /dev/null @@ -1,43 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 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; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/ConversationStatistics.ts b/src/api/resources/unstable/types/ConversationStatistics.ts deleted file mode 100644 index 8491c58f..00000000 --- a/src/api/resources/unstable/types/ConversationStatistics.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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; - /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ - adjusted_handling_time?: number; -} diff --git a/src/api/resources/unstable/types/ConversationTagsUpdated.ts b/src/api/resources/unstable/types/ConversationTagsUpdated.ts deleted file mode 100644 index 556dd3e0..00000000 --- a/src/api/resources/unstable/types/ConversationTagsUpdated.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about tags that were added or removed from a conversation for conversation part type conversation_tags_updated. - */ -export interface ConversationTagsUpdated { - /** Array of tag names that were added */ - tags_added?: string[]; - /** Array of tag names that were removed */ - tags_removed?: string[]; -} diff --git a/src/api/resources/unstable/types/ConversationTeammates.ts b/src/api/resources/unstable/types/ConversationTeammates.ts deleted file mode 100644 index 3932494d..00000000 --- a/src/api/resources/unstable/types/ConversationTeammates.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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/CreateArticleRequest.ts b/src/api/resources/unstable/types/CreateArticleRequest.ts deleted file mode 100644 index fae9a9e6..00000000 --- a/src/api/resources/unstable/types/CreateArticleRequest.ts +++ /dev/null @@ -1,33 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * You can create an Article - */ -export interface CreateArticleRequest { - /** 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?: CreateArticleRequest.State; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: string; - translated_content?: Intercom.unstable.ArticleTranslatedContent; -} - -export namespace CreateArticleRequest { - /** 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/CreateDataAttributeRequest.ts b/src/api/resources/unstable/types/CreateDataAttributeRequest.ts deleted file mode 100644 index e2abd5d2..00000000 --- a/src/api/resources/unstable/types/CreateDataAttributeRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataAttributeRequest = - | { - data_type?: "options" | undefined; - options: { - value?: string | undefined; - }[]; - } - | { - data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; - }; diff --git a/src/api/resources/unstable/types/CreateInternalArticleRequest.ts b/src/api/resources/unstable/types/CreateInternalArticleRequest.ts deleted file mode 100644 index f971e918..00000000 --- a/src/api/resources/unstable/types/CreateInternalArticleRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create an Internal Article - */ -export interface CreateInternalArticleRequest { - /** The title of the article. */ - title: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id: number; - /** The id of the owner of the article. */ - owner_id: number; -} diff --git a/src/api/resources/unstable/types/CreateMessageRequest.ts b/src/api/resources/unstable/types/CreateMessageRequest.ts deleted file mode 100644 index b9bc1f58..00000000 --- a/src/api/resources/unstable/types/CreateMessageRequest.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create a message - */ -export type CreateMessageRequest = unknown | undefined; diff --git a/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts b/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts deleted file mode 100644 index 9a465e5c..00000000 --- a/src/api/resources/unstable/types/CreateOrUpdateCompanyRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update a Company - */ -export interface CreateOrUpdateCompanyRequest { - /** The name of the Company */ - name?: string; - /** The company id you have defined for the company. Can't be updated */ - company_id?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** The time the company was created by you. */ - remote_created_at?: number; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts b/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts deleted file mode 100644 index 7dfd1b3f..00000000 --- a/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/CreatePhoneSwitchRequest.ts b/src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts deleted file mode 100644 index 825757f8..00000000 --- a/src/api/resources/unstable/types/CreatePhoneSwitchRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * You can create an phone switch - */ -export interface CreatePhoneSwitchRequest { - /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ - phone: string; - custom_attributes?: Intercom.unstable.CustomAttributes; -} diff --git a/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts b/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts deleted file mode 100644 index 31c13aad..00000000 --- a/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 9ec9fb5c..00000000 --- a/src/api/resources/unstable/types/CreateTicketRequestBody.ts +++ /dev/null @@ -1,48 +0,0 @@ -// 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/CreateTicketTypeRequest.ts b/src/api/resources/unstable/types/CreateTicketTypeRequest.ts deleted file mode 100644 index eebc72da..00000000 --- a/src/api/resources/unstable/types/CreateTicketTypeRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The request payload for creating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) - */ -export interface CreateTicketTypeRequest { - /** The name of the ticket type. */ - name: string; - /** The description of the ticket type. */ - description?: string; - /** Category of the Ticket Type. */ - category?: CreateTicketTypeRequest.Category; - /** The icon of the ticket type. */ - icon?: string; - /** 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 CreateTicketTypeRequest { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/types/CursorPages.ts b/src/api/resources/unstable/types/CursorPages.ts deleted file mode 100644 index 28a01ed3..00000000 --- a/src/api/resources/unstable/types/CursorPages.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 54471392..00000000 --- a/src/api/resources/unstable/types/CustomActionFinished.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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 const Result = { - Success: "success", - Failed: "failed", - } as const; - export type Result = (typeof Result)[keyof typeof Result]; - } -} diff --git a/src/api/resources/unstable/types/CustomActionStarted.ts b/src/api/resources/unstable/types/CustomActionStarted.ts deleted file mode 100644 index 18114f6c..00000000 --- a/src/api/resources/unstable/types/CustomActionStarted.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index c2086e14..00000000 --- a/src/api/resources/unstable/types/CustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 9afa1dd6..00000000 --- a/src/api/resources/unstable/types/CustomChannelAttribute.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 6a638105..00000000 --- a/src/api/resources/unstable/types/CustomChannelBaseEvent.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 7d11a83c..00000000 --- a/src/api/resources/unstable/types/CustomChannelContact.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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. Required for user type. */ - name?: string; - /** Email address of the contact. Required for user type. */ - email?: string; -} - -export namespace CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts b/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts deleted file mode 100644 index 238b883d..00000000 --- a/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 4c14eba9..00000000 --- a/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 98e68588..00000000 --- a/src/api/resources/unstable/types/CustomObjectInstanceList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index d86d11c7..00000000 --- a/src/api/resources/unstable/types/CustomerRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index f8b6055b..00000000 --- a/src/api/resources/unstable/types/DataAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 1fa73fc8..00000000 --- a/src/api/resources/unstable/types/DataEventList.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 0badccff..00000000 --- a/src/api/resources/unstable/types/DataEventSummary.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 9f0d9192..00000000 --- a/src/api/resources/unstable/types/DataEventSummaryItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// 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 deleted file mode 100644 index 8c268f7e..00000000 --- a/src/api/resources/unstable/types/DataExportCsv.ts +++ /dev/null @@ -1,59 +0,0 @@ -// 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 deleted file mode 100644 index 63964732..00000000 --- a/src/api/resources/unstable/types/Datetime.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 deleted file mode 100644 index 5667114c..00000000 --- a/src/api/resources/unstable/types/DeletedArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 4d03d936..00000000 --- a/src/api/resources/unstable/types/DeletedCollectionObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index b5ee6cf6..00000000 --- a/src/api/resources/unstable/types/DeletedCompanyObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/DeletedInternalArticleObject.ts b/src/api/resources/unstable/types/DeletedInternalArticleObject.ts deleted file mode 100644 index 47d5060b..00000000 --- a/src/api/resources/unstable/types/DeletedInternalArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedInternalArticleObject { - /** The unique identifier for the internal article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - internal_article */ - object?: "internal_article"; - /** Whether the internal article 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 deleted file mode 100644 index a22b393b..00000000 --- a/src/api/resources/unstable/types/DeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 7e8d234d..00000000 --- a/src/api/resources/unstable/types/EmailAddressHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 022108cf..00000000 --- a/src/api/resources/unstable/types/EmailMessageMetadata.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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[]; - /** The unique identifier for the email message as specified in the Message-ID header */ - message_id?: string; -} diff --git a/src/api/resources/unstable/types/Error_.ts b/src/api/resources/unstable/types/Error_.ts deleted file mode 100644 index 91e726ed..00000000 --- a/src/api/resources/unstable/types/Error_.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 422603dc..00000000 --- a/src/api/resources/unstable/types/EventDetails.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -export type EventDetails = - | Intercom.unstable.ConversationAttributeUpdatedByWorkflow - | Intercom.unstable.ConversationAttributeUpdatedByAdmin - | Intercom.unstable.ConversationAttributeUpdatedByUser - | Intercom.unstable.CustomActionStarted - | Intercom.unstable.CustomActionFinished - | Intercom.unstable.OperatorWorkflowEvent - | Intercom.unstable.ConversationTagsUpdated - | Intercom.unstable.Snoozed - | Intercom.unstable.PriorityChanged - | Intercom.unstable.ConversationSlaAppliedByRule - | Intercom.unstable.ConversationSlaAppliedByWorkflow - | Intercom.unstable.ConversationSlaTargetMissed - | Intercom.unstable.ConversationSlaPaused - | Intercom.unstable.ConversationSlaUnpaused - | Intercom.unstable.ConversationSlaRemoved; diff --git a/src/api/resources/unstable/types/FileAttribute.ts b/src/api/resources/unstable/types/FileAttribute.ts deleted file mode 100644 index b8fab036..00000000 --- a/src/api/resources/unstable/types/FileAttribute.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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 deleted file mode 100644 index 68c5b320..00000000 --- a/src/api/resources/unstable/types/GroupContent.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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?: "group_content"; - /** 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 deleted file mode 100644 index c7b9933b..00000000 --- a/src/api/resources/unstable/types/GroupTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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?: "group_translated_content"; - /** 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/HandlingEvent.ts b/src/api/resources/unstable/types/HandlingEvent.ts deleted file mode 100644 index f6d3e9d6..00000000 --- a/src/api/resources/unstable/types/HandlingEvent.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A pause or resume event for a conversation - */ -export interface HandlingEvent { - teammate: Intercom.unstable.TeammateReference; - /** The type of handling event */ - type: HandlingEvent.Type; - /** ISO8601 timestamp when the event occurred */ - timestamp: string; - /** Optional reason for the event (e.g., "Paused", "Away") */ - reason?: string; -} - -export namespace HandlingEvent { - /** The type of handling event */ - export const Type = { - Paused: "paused", - Resumed: "resumed", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/HandlingEventList.ts b/src/api/resources/unstable/types/HandlingEventList.ts deleted file mode 100644 index 57dfe2d2..00000000 --- a/src/api/resources/unstable/types/HandlingEventList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A list of handling events for a conversation - */ -export interface HandlingEventList { - /** Array of handling events */ - handling_events?: Intercom.unstable.HandlingEvent[]; -} diff --git a/src/api/resources/unstable/types/InternalArticleList.ts b/src/api/resources/unstable/types/InternalArticleList.ts deleted file mode 100644 index 5f5f6df8..00000000 --- a/src/api/resources/unstable/types/InternalArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * This will return a list of internal articles for the App. - */ -export interface InternalArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.unstable.CursorPages; - /** A count of the total number of internal articles. */ - total_count?: number; - /** An array of Internal Article objects */ - data?: Intercom.unstable.InternalArticleListItem[]; -} diff --git a/src/api/resources/unstable/types/LinkedObject.ts b/src/api/resources/unstable/types/LinkedObject.ts deleted file mode 100644 index 27fe77b5..00000000 --- a/src/api/resources/unstable/types/LinkedObject.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 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?: LinkedObject.Category; -} - -export namespace LinkedObject { - /** ticket or conversation */ - export const Type = { - Ticket: "ticket", - Conversation: "conversation", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - /** Category of the Linked Ticket Object. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/resources/unstable/types/LinkedObjectList.ts b/src/api/resources/unstable/types/LinkedObjectList.ts deleted file mode 100644 index b17171e1..00000000 --- a/src/api/resources/unstable/types/LinkedObjectList.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 4d834701..00000000 --- a/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const Operator = { - And: "AND", - Or: "OR", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - 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 deleted file mode 100644 index 9735b4fc..00000000 --- a/src/api/resources/unstable/types/NewsItemRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/resources/unstable/types/NotFoundErrorBody.ts b/src/api/resources/unstable/types/NotFoundErrorBody.ts deleted file mode 100644 index de9109f3..00000000 --- a/src/api/resources/unstable/types/NotFoundErrorBody.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 deleted file mode 100644 index 0f1e8fe4..00000000 --- a/src/api/resources/unstable/types/NoteList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * A paginated list of notes associated with a contact or a company. - */ -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 deleted file mode 100644 index b3e63714..00000000 --- a/src/api/resources/unstable/types/OpenConversationRequest.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 deleted file mode 100644 index df8629d3..00000000 --- a/src/api/resources/unstable/types/OperatorWorkflowEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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 deleted file mode 100644 index 59d698ff..00000000 --- a/src/api/resources/unstable/types/PagesLink.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 deleted file mode 100644 index 64972bf9..00000000 --- a/src/api/resources/unstable/types/PaginatedResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const Type = { - List: "list", - ConversationList: "conversation.list", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/PaginatedResponseDataItem.ts b/src/api/resources/unstable/types/PaginatedResponseDataItem.ts deleted file mode 100644 index 65655304..00000000 --- a/src/api/resources/unstable/types/PaginatedResponseDataItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 3c01b778..00000000 --- a/src/api/resources/unstable/types/PartAttachment.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index 5fbeb892..00000000 --- a/src/api/resources/unstable/types/PhoneSwitch.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/PriorityChanged.ts b/src/api/resources/unstable/types/PriorityChanged.ts deleted file mode 100644 index f09b55df..00000000 --- a/src/api/resources/unstable/types/PriorityChanged.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about priority changes for conversation part type priority_changed. - */ -export interface PriorityChanged { - /** Current priority state */ - current_priority?: PriorityChanged.CurrentPriority; - /** Previous priority state */ - previous_priority?: PriorityChanged.PreviousPriority; -} - -export namespace PriorityChanged { - /** Current priority state */ - export const CurrentPriority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type CurrentPriority = (typeof CurrentPriority)[keyof typeof CurrentPriority]; - /** Previous priority state */ - export const PreviousPriority = { - Priority: "priority", - NotPriority: "not_priority", - } as const; - export type PreviousPriority = (typeof PreviousPriority)[keyof typeof PreviousPriority]; -} diff --git a/src/api/resources/unstable/types/QuickReplyOption.ts b/src/api/resources/unstable/types/QuickReplyOption.ts deleted file mode 100644 index 8de2d400..00000000 --- a/src/api/resources/unstable/types/QuickReplyOption.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 194d11d0..00000000 --- a/src/api/resources/unstable/types/Recipient.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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 const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/RedactConversationRequest.ts b/src/api/resources/unstable/types/RedactConversationRequest.ts deleted file mode 100644 index f4845e8e..00000000 --- a/src/api/resources/unstable/types/RedactConversationRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 7c9c82a3..00000000 --- a/src/api/resources/unstable/types/Reference.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/RegisterFinVoiceCallRequest.ts b/src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts deleted file mode 100644 index 2fd07f21..00000000 --- a/src/api/resources/unstable/types/RegisterFinVoiceCallRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Register a Fin Voice call with Intercom - */ -export interface RegisterFinVoiceCallRequest { - /** Phone number in E.164 format for the call */ - phone_number: string; - /** External call identifier from the call provider */ - call_id: string; - /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ - source?: RegisterFinVoiceCallRequest.Source; - /** Additional metadata about the call */ - data?: Record; -} - -export namespace RegisterFinVoiceCallRequest { - /** Source of the call. Can be "five9", "zoom_phone", or defaults to "aws_connect" */ - export const Source = { - Five9: "five9", - ZoomPhone: "zoom_phone", - AwsConnect: "aws_connect", - } as const; - export type Source = (typeof Source)[keyof typeof Source]; -} diff --git a/src/api/resources/unstable/types/ReplyConversationRequestBody.ts b/src/api/resources/unstable/types/ReplyConversationRequestBody.ts deleted file mode 100644 index 3f05df15..00000000 --- a/src/api/resources/unstable/types/ReplyConversationRequestBody.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -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 deleted file mode 100644 index 796d8fc5..00000000 --- a/src/api/resources/unstable/types/SearchRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 7a3ae83b..00000000 --- a/src/api/resources/unstable/types/SegmentList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 58808cb4..00000000 --- a/src/api/resources/unstable/types/SingleFilterSearchRequest.ts +++ /dev/null @@ -1,30 +0,0 @@ -// 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 const Operator = { - EqualTo: "=", - NotEquals: "!=", - In: "IN", - Nin: "NIN", - LessThan: "<", - GreaterThan: ">", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - /** - * 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 deleted file mode 100644 index 3ea77f62..00000000 --- a/src/api/resources/unstable/types/SlaApplied.ts +++ /dev/null @@ -1,35 +0,0 @@ -// 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 const SlaStatus = { - Hit: "hit", - Missed: "missed", - Cancelled: "cancelled", - Active: "active", - } as const; - export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; -} diff --git a/src/api/resources/unstable/types/SnoozeConversationRequest.ts b/src/api/resources/unstable/types/SnoozeConversationRequest.ts deleted file mode 100644 index 7e3e7061..00000000 --- a/src/api/resources/unstable/types/SnoozeConversationRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/Snoozed.ts b/src/api/resources/unstable/types/Snoozed.ts deleted file mode 100644 index c8ea22fc..00000000 --- a/src/api/resources/unstable/types/Snoozed.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Contains details about conversation snooze timing for conversation part type snoozed. - */ -export interface Snoozed { - /** Human-readable description of snooze duration */ - until?: string; - /** ISO timestamp for custom snooze times (null for general snoozes) */ - custom_until_time?: string; -} diff --git a/src/api/resources/unstable/types/SocialProfile.ts b/src/api/resources/unstable/types/SocialProfile.ts deleted file mode 100644 index 5beba459..00000000 --- a/src/api/resources/unstable/types/SocialProfile.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 6fc82b73..00000000 --- a/src/api/resources/unstable/types/StartingAfterPaging.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 977b74d8..00000000 --- a/src/api/resources/unstable/types/SubscriptionTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 4f4affb5..00000000 --- a/src/api/resources/unstable/types/TagCompanyRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// 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 deleted file mode 100644 index 5aba89c4..00000000 --- a/src/api/resources/unstable/types/TagList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index fc697987..00000000 --- a/src/api/resources/unstable/types/TagMultipleUsersRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 deleted file mode 100644 index e968cf71..00000000 --- a/src/api/resources/unstable/types/Tags.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index c711e412..00000000 --- a/src/api/resources/unstable/types/TeamList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 07d6bae5..00000000 --- a/src/api/resources/unstable/types/TeamPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/TeammateReference.ts b/src/api/resources/unstable/types/TeammateReference.ts deleted file mode 100644 index 913ea0b2..00000000 --- a/src/api/resources/unstable/types/TeammateReference.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A reference to a teammate (admin, team, or bot) - */ -export interface TeammateReference { - /** The type of teammate */ - type: TeammateReference.Type; - /** The unique identifier of the teammate */ - id: number; - /** The display name of the teammate */ - name: string; - /** The email address of the teammate (optional for teams/bots) */ - email?: string; -} - -export namespace TeammateReference { - /** The type of teammate */ - export const Type = { - Admin: "admin", - Team: "team", - Bot: "bot", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/TicketCustomAttributes.ts b/src/api/resources/unstable/types/TicketCustomAttributes.ts deleted file mode 100644 index c3cb349e..00000000 --- a/src/api/resources/unstable/types/TicketCustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index b1545342..00000000 --- a/src/api/resources/unstable/types/TicketList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index e0ea7ff3..00000000 --- a/src/api/resources/unstable/types/TicketPartAuthor.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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 const Type = { - Admin: "admin", - Bot: "bot", - Team: "team", - User: "user", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/resources/unstable/types/TicketParts.ts b/src/api/resources/unstable/types/TicketParts.ts deleted file mode 100644 index 95c99271..00000000 --- a/src/api/resources/unstable/types/TicketParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 1a648076..00000000 --- a/src/api/resources/unstable/types/TicketReply.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 const PartType = { - Note: "note", - Comment: "comment", - QuickReply: "quick_reply", - } as const; - export type PartType = (typeof PartType)[keyof typeof PartType]; -} diff --git a/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts b/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts deleted file mode 100644 index 6f54ade8..00000000 --- a/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index 51e43516..00000000 --- a/src/api/resources/unstable/types/TicketStateList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index f634dd96..00000000 --- a/src/api/resources/unstable/types/TicketTypeAttribute.ts +++ /dev/null @@ -1,41 +0,0 @@ -// 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 deleted file mode 100644 index 1466cda0..00000000 --- a/src/api/resources/unstable/types/TicketTypeAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 7b839c67..00000000 --- a/src/api/resources/unstable/types/TicketTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 3d656a16..00000000 --- a/src/api/resources/unstable/types/Translation.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index 09886bd1..00000000 --- a/src/api/resources/unstable/types/UntagCompanyRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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/UpdateDataAttributeRequestBody.ts b/src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts deleted file mode 100644 index 6524ae99..00000000 --- a/src/api/resources/unstable/types/UpdateDataAttributeRequestBody.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type UpdateDataAttributeRequestBody = - | { - options: { - value?: string | undefined; - }[]; - } - | unknown; diff --git a/src/api/resources/unstable/types/Visitor.ts b/src/api/resources/unstable/types/Visitor.ts deleted file mode 100644 index 32dcf169..00000000 --- a/src/api/resources/unstable/types/Visitor.ts +++ /dev/null @@ -1,136 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../../../index.js"; - -/** - * 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 deleted file mode 100644 index 6a3cc196..00000000 --- a/src/api/resources/unstable/types/VisitorDeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index b1d0e8d8..00000000 --- a/src/api/resources/unstable/types/WhatsappMessageStatusList.ts +++ /dev/null @@ -1,67 +0,0 @@ -// 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 const Status = { - Sent: "sent", - Delivered: "delivered", - Read: "read", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/resources/unstable/types/WorkflowExport.ts b/src/api/resources/unstable/types/WorkflowExport.ts deleted file mode 100644 index 93531949..00000000 --- a/src/api/resources/unstable/types/WorkflowExport.ts +++ /dev/null @@ -1,59 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * A workflow export containing the complete workflow configuration. - */ -export interface WorkflowExport { - /** The version of the export format. */ - export_version?: string; - /** The timestamp when the export was generated. */ - exported_at?: string; - /** The workspace identifier. */ - app_id?: number; - /** The workflow configuration. */ - workflow?: WorkflowExport.Workflow; -} - -export namespace WorkflowExport { - /** - * The workflow configuration. - */ - export interface Workflow { - /** The unique identifier for the workflow. */ - id?: string; - /** The title of the workflow. */ - title?: string; - /** The description of the workflow. */ - description?: string; - /** The type of trigger that starts this workflow. */ - trigger_type?: string; - /** The current state of the workflow. */ - state?: Workflow.State; - /** The channels this workflow targets. */ - target_channels?: string[]; - /** The preferred devices for this workflow. */ - preferred_devices?: string[]; - /** When the workflow was created. */ - created_at?: string; - /** When the workflow was last updated. */ - updated_at?: string; - /** The targeting rules for this workflow. */ - targeting?: Record; - /** The current snapshot of workflow steps and configuration. */ - snapshot?: Record; - /** Custom attributes defined for this workflow. */ - attributes?: Record[]; - /** Rules embedded within the workflow steps. */ - embedded_rules?: Record[]; - } - - export namespace Workflow { - /** The current state of the workflow. */ - export const State = { - Live: "live", - Draft: "draft", - Paused: "paused", - } as const; - export type State = (typeof State)[keyof typeof State]; - } -} diff --git a/src/api/resources/unstable/types/index.ts b/src/api/resources/unstable/types/index.ts deleted file mode 100644 index 5b8c268e..00000000 --- a/src/api/resources/unstable/types/index.ts +++ /dev/null @@ -1,168 +0,0 @@ -export * from "./ActivityLog.js"; -export * from "./ActivityLogList.js"; -export * from "./ActivityLogMetadata.js"; -export * from "./AddressableList.js"; -export * from "./AdminList.js"; -export * from "./AdminPriorityLevel.js"; -export * from "./AdminReplyConversationRequest.js"; -export * from "./AdminReplyTicketRequest.js"; -export * from "./AdminWithApp.js"; -export * from "./AiCallResponse.js"; -export * from "./App.js"; -export * from "./ArticleContent.js"; -export * from "./ArticleList.js"; -export * from "./ArticleStatistics.js"; -export * from "./ArticleTranslatedContent.js"; -export * from "./AssignConversationRequest.js"; -export * from "./AwayStatusReason.js"; -export * from "./CallList.js"; -export * from "./CloseConversationRequest.js"; -export * from "./CollectionList.js"; -export * from "./CompanyAttachedContacts.js"; -export * from "./CompanyAttachedSegments.js"; -export * from "./CompanyData.js"; -export * from "./CompanyList.js"; -export * from "./CompanyScroll.js"; -export * from "./ContactArchived.js"; -export * from "./ContactAttachedCompanies.js"; -export * from "./ContactBlocked.js"; -export * from "./ContactCompanies.js"; -export * from "./ContactDeleted.js"; -export * from "./ContactList.js"; -export * from "./ContactLocation.js"; -export * from "./ContactNotes.js"; -export * from "./ContactReference.js"; -export * from "./ContactReplyBaseRequest.js"; -export * from "./ContactReplyConversationRequest.js"; -export * from "./ContactReplyEmailRequest.js"; -export * from "./ContactReplyIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketEmailRequest.js"; -export * from "./ContactReplyTicketIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketRequest.js"; -export * from "./ContactReplyTicketUserIdRequest.js"; -export * from "./ContactReplyUserIdRequest.js"; -export * from "./ContactSegments.js"; -export * from "./ContactSocialProfiles.js"; -export * from "./ContactSubscriptionTypes.js"; -export * from "./ContactTags.js"; -export * from "./ContactUnarchived.js"; -export * from "./ContentSourcesList.js"; -export * from "./ConversationAttachmentFiles.js"; -export * from "./ConversationAttributeUpdatedByAdmin.js"; -export * from "./ConversationAttributeUpdatedByUser.js"; -export * from "./ConversationAttributeUpdatedByWorkflow.js"; -export * from "./ConversationContacts.js"; -export * from "./ConversationDeleted.js"; -export * from "./ConversationFirstContactReply.js"; -export * from "./ConversationList.js"; -export * from "./ConversationPart.js"; -export * from "./ConversationPartAuthor.js"; -export * from "./ConversationPartMetadata.js"; -export * from "./ConversationParts.js"; -export * from "./ConversationRating.js"; -export * from "./ConversationResponseTime.js"; -export * from "./ConversationSlaAppliedByRule.js"; -export * from "./ConversationSlaAppliedByWorkflow.js"; -export * from "./ConversationSlaPaused.js"; -export * from "./ConversationSlaRemoved.js"; -export * from "./ConversationSlaTargetMissed.js"; -export * from "./ConversationSlaUnpaused.js"; -export * from "./ConversationSource.js"; -export * from "./ConversationStatistics.js"; -export * from "./ConversationTagsUpdated.js"; -export * from "./ConversationTeammates.js"; -export * from "./CreateArticleRequest.js"; -export * from "./CreateDataAttributeRequest.js"; -export * from "./CreateInternalArticleRequest.js"; -export * from "./CreateMessageRequest.js"; -export * from "./CreateOrUpdateCompanyRequest.js"; -export * from "./CreateOrUpdateTagRequest.js"; -export * from "./CreatePhoneSwitchRequest.js"; -export * from "./CreateTicketReplyWithCommentRequest.js"; -export * from "./CreateTicketRequestBody.js"; -export * from "./CreateTicketTypeRequest.js"; -export * from "./CursorPages.js"; -export * from "./CustomActionFinished.js"; -export * from "./CustomActionStarted.js"; -export * from "./CustomAttributes.js"; -export * from "./CustomChannelAttribute.js"; -export * from "./CustomChannelBaseEvent.js"; -export * from "./CustomChannelContact.js"; -export * from "./CustomChannelNotificationResponse.js"; -export * from "./CustomerRequest.js"; -export * from "./CustomObjectInstanceDeleted.js"; -export * from "./CustomObjectInstanceList.js"; -export * from "./DataAttributeList.js"; -export * from "./DataEventList.js"; -export * from "./DataEventSummary.js"; -export * from "./DataEventSummaryItem.js"; -export * from "./DataExportCsv.js"; -export * from "./Datetime.js"; -export * from "./DeletedArticleObject.js"; -export * from "./DeletedCollectionObject.js"; -export * from "./DeletedCompanyObject.js"; -export * from "./DeletedInternalArticleObject.js"; -export * from "./DeletedObject.js"; -export * from "./EmailAddressHeader.js"; -export * from "./EmailMessageMetadata.js"; -export * from "./Error_.js"; -export * from "./EventDetails.js"; -export * from "./FileAttribute.js"; -export * from "./GroupContent.js"; -export * from "./GroupTranslatedContent.js"; -export * from "./HandlingEvent.js"; -export * from "./HandlingEventList.js"; -export * from "./InternalArticleList.js"; -export * from "./LinkedObject.js"; -export * from "./LinkedObjectList.js"; -export * from "./MultipleFilterSearchRequest.js"; -export * from "./NewsItemRequest.js"; -export * from "./NoteList.js"; -export * from "./NotFoundErrorBody.js"; -export * from "./OpenConversationRequest.js"; -export * from "./OperatorWorkflowEvent.js"; -export * from "./PagesLink.js"; -export * from "./PaginatedResponse.js"; -export * from "./PaginatedResponseDataItem.js"; -export * from "./PartAttachment.js"; -export * from "./PhoneSwitch.js"; -export * from "./PriorityChanged.js"; -export * from "./QuickReplyOption.js"; -export * from "./Recipient.js"; -export * from "./RedactConversationRequest.js"; -export * from "./Reference.js"; -export * from "./RegisterFinVoiceCallRequest.js"; -export * from "./ReplyConversationRequestBody.js"; -export * from "./SearchRequest.js"; -export * from "./SegmentList.js"; -export * from "./SingleFilterSearchRequest.js"; -export * from "./SlaApplied.js"; -export * from "./SnoozeConversationRequest.js"; -export * from "./Snoozed.js"; -export * from "./SocialProfile.js"; -export * from "./StartingAfterPaging.js"; -export * from "./SubscriptionTypeList.js"; -export * from "./TagCompanyRequest.js"; -export * from "./TagList.js"; -export * from "./TagMultipleUsersRequest.js"; -export * from "./Tags.js"; -export * from "./TeamList.js"; -export * from "./TeammateReference.js"; -export * from "./TeamPriorityLevel.js"; -export * from "./TicketCustomAttributes.js"; -export * from "./TicketList.js"; -export * from "./TicketPartAuthor.js"; -export * from "./TicketParts.js"; -export * from "./TicketReply.js"; -export * from "./TicketRequestCustomAttributes.js"; -export * from "./TicketStateList.js"; -export * from "./TicketTypeAttribute.js"; -export * from "./TicketTypeAttributeList.js"; -export * from "./TicketTypeList.js"; -export * from "./Translation.js"; -export * from "./UntagCompanyRequest.js"; -export * from "./UpdateDataAttributeRequestBody.js"; -export * from "./Visitor.js"; -export * from "./VisitorDeletedObject.js"; -export * from "./WhatsappMessageStatusList.js"; -export * from "./WorkflowExport.js"; diff --git a/src/api/resources/visitors/client/Client.ts b/src/api/resources/visitors/client/Client.ts deleted file mode 100644 index 097e5ada..00000000 --- a/src/api/resources/visitors/client/Client.ts +++ /dev/null @@ -1,274 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; -import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; -import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; -import * as core from "../../../../core/index.js"; -import * as environments from "../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../errors/index.js"; -import * as Intercom from "../../../index.js"; - -export declare namespace VisitorsClient { - export interface Options extends BaseClientOptions {} - - export interface RequestOptions extends BaseRequestOptions {} -} - -/** - * Everything about your Visitors - */ -export class VisitorsClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: VisitorsClient.Options = {}) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * You can fetch the details of a single visitor. - * - * @param {Intercom.FindVisitorRequest} request - * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.visitors.find({ - * user_id: "user_id" - * }) - */ - public find( - request: Intercom.FindVisitorRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); - } - - private async __find( - request: Intercom.FindVisitorRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const { user_id: userId } = request; - const _queryParams: Record = {}; - _queryParams.user_id = userId; - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors", - ), - method: "GET", - headers: _headers, - queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Visitor | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/visitors"); - } - - /** - * 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.UpdateVisitorRequest} request - * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * @throws {@link Intercom.NotFoundError} - * - * @example - * await client.visitors.update({ - * id: "6762f30c1bb69f9f2193bc5e", - * name: "Gareth Bale" - * }) - * - * @example - * await client.visitors.update({ - * user_id: "fail", - * name: "Christian Fail" - * }) - */ - public update( - request: Intercom.UpdateVisitorRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); - } - - private async __update( - request: Intercom.UpdateVisitorRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors", - ), - method: "PUT", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: _response.body as Intercom.Visitor | 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_, - _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, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/visitors"); - } - - /** - * 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.MergeVisitorToContactRequest} request - * @param {VisitorsClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Intercom.UnauthorizedError} - * - * @example - * await client.visitors.mergeToContact({ - * type: "user", - * user: { - * id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - * email: "foo@bar.com" - * }, - * visitor: { - * user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" - * } - * }) - */ - public mergeToContact( - request: Intercom.MergeVisitorToContactRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__mergeToContact(request, requestOptions)); - } - - private async __mergeToContact( - request: Intercom.MergeVisitorToContactRequest, - requestOptions?: VisitorsClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - const _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - mergeOnlyDefinedHeaders({ "Intercom-Version": requestOptions?.version }), - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "visitors/convert", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryParameters: requestOptions?.queryParams, - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 20) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - 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_, - _response.rawResponse, - ); - default: - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/visitors/convert"); - } -} diff --git a/src/api/resources/visitors/client/index.ts b/src/api/resources/visitors/client/index.ts deleted file mode 100644 index 195f9aa8..00000000 --- a/src/api/resources/visitors/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./requests/index.js"; diff --git a/src/api/resources/visitors/client/requests/FindVisitorRequest.ts b/src/api/resources/visitors/client/requests/FindVisitorRequest.ts deleted file mode 100644 index 45db1e2d..00000000 --- a/src/api/resources/visitors/client/requests/FindVisitorRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * user_id: "user_id" - * } - */ -export interface FindVisitorRequest { - /** The user_id of the Visitor you want to retrieve. */ - user_id: string; -} diff --git a/src/api/resources/visitors/client/requests/MergeVisitorToContactRequest.ts b/src/api/resources/visitors/client/requests/MergeVisitorToContactRequest.ts deleted file mode 100644 index d469c38a..00000000 --- a/src/api/resources/visitors/client/requests/MergeVisitorToContactRequest.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * @example - * { - * type: "user", - * user: { - * id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - * email: "foo@bar.com" - * }, - * visitor: { - * user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" - * } - * } - */ -export interface MergeVisitorToContactRequest { - /** Represents the role of the Contact model. Accepts `lead` or `user`. */ - type: string; - /** The unique identifiers retained after converting or merging. */ - user: MergeVisitorToContactRequest.User; - /** The unique identifiers to convert a single Visitor. */ - visitor: MergeVisitorToContactRequest.Visitor; -} - -export namespace MergeVisitorToContactRequest { - /** - * The unique identifiers retained after converting or merging. - */ - export type User = - | { - id: string; - email?: string | undefined; - } - | { - user_id: string; - email?: string | undefined; - }; - /** - * The unique identifiers to convert a single Visitor. - */ - export type Visitor = - | { - id: string; - } - | { - user_id: string; - } - | { - email: string; - }; -} diff --git a/src/api/resources/visitors/client/requests/index.ts b/src/api/resources/visitors/client/requests/index.ts deleted file mode 100644 index f956dfd4..00000000 --- a/src/api/resources/visitors/client/requests/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type { FindVisitorRequest } from "./FindVisitorRequest.js"; -export type { MergeVisitorToContactRequest } from "./MergeVisitorToContactRequest.js"; diff --git a/src/api/resources/visitors/index.ts b/src/api/resources/visitors/index.ts deleted file mode 100644 index 914b8c3c..00000000 --- a/src/api/resources/visitors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/api/types/ActivityLog.ts b/src/api/types/ActivityLog.ts deleted file mode 100644 index eea2e6fd..00000000 --- a/src/api/types/ActivityLog.ts +++ /dev/null @@ -1,137 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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 const ActivityType = { - AdminConversationAssignmentLimitChange: "admin_conversation_assignment_limit_change", - AdminTicketAssignmentLimitChange: "admin_ticket_assignment_limit_change", - AdminAwayModeChange: "admin_away_mode_change", - AdminDeletion: "admin_deletion", - AdminDeprovisioned: "admin_deprovisioned", - AdminImpersonationEnd: "admin_impersonation_end", - AdminImpersonationStart: "admin_impersonation_start", - AdminImpersonationConsentApproved: "admin_impersonation_consent_approved", - AdminImpersonationConsentRevoked: "admin_impersonation_consent_revoked", - 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", - AutomaticAwayModeSettingChange: "automatic_away_mode_setting_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", - CustomAuthenticationTokenCreation: "custom_authentication_token_creation", - HelpCenterSettingsChange: "help_center_settings_change", - InboundConversationsChange: "inbound_conversations_change", - InboxAccessChange: "inbox_access_change", - MacroCreation: "macro_creation", - MacroDeletion: "macro_deletion", - MacroUpdate: "macro_update", - MaliciousDomainsSettingChange: "malicious_domains_setting_change", - MessageDeletion: "message_deletion", - MessageStateChange: "message_state_change", - MessengerApiSecretCreation: "messenger_api_secret_creation", - MessengerApiSecretDeletion: "messenger_api_secret_deletion", - MessengerLookAndFeelChange: "messenger_look_and_feel_change", - MessengerSearchRequiredChange: "messenger_search_required_change", - MessengerSpacesChange: "messenger_spaces_change", - OauthTokenRevocation: "oauth_token_revocation", - 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", - SeriesCreation: "series_creation", - SeriesDeletion: "series_deletion", - SeriesSettingsUpdate: "series_settings_update", - SeriesStatusChange: "series_status_change", - SeriesUpdate: "series_update", - StripInboundEmailLinksChange: "strip_inbound_email_links_change", - TemporaryExpectationChange: "temporary_expectation_change", - TeamAssignmentLimitChange: "team_assignment_limit_change", - TrustedDomainsSettingChange: "trusted_domains_setting_change", - UnassignUnsnoozedAtCapacitySettingChange: "unassign_unsnoozed_at_capacity_setting_change", - UpfrontEmailCollectionChange: "upfront_email_collection_change", - AllowedAttachmentFiletypesSettingChange: "allowed_attachment_filetypes_setting_change", - AttachUploadsInlineSettingChange: "attach_uploads_inline_setting_change", - TeammateGifsSettingChange: "teammate_gifs_setting_change", - UserCameraAttachmentsSettingChange: "user_camera_attachments_setting_change", - UserConversationAttachmentsSettingChange: "user_conversation_attachments_setting_change", - UserFileAttachmentsSettingChange: "user_file_attachments_setting_change", - UserGifsSettingChange: "user_gifs_setting_change", - UserMediaAttachmentsSettingChange: "user_media_attachments_setting_change", - UserVoiceNotesSettingChange: "user_voice_notes_setting_change", - WelcomeMessageChange: "welcome_message_change", - WorkspaceDeletionRequest: "workspace_deletion_request", - } as const; - export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; -} diff --git a/src/api/types/ActivityLogList.ts b/src/api/types/ActivityLogList.ts deleted file mode 100644 index 6a1253cc..00000000 --- a/src/api/types/ActivityLogList.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.CursorPages; - /** An array of activity logs */ - activity_logs?: (Intercom.ActivityLog | undefined)[]; -} diff --git a/src/api/types/ActivityLogMetadata.ts b/src/api/types/ActivityLogMetadata.ts deleted file mode 100644 index ed4bfcf2..00000000 --- a/src/api/types/ActivityLogMetadata.ts +++ /dev/null @@ -1,55 +0,0 @@ -// 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; - /** The conversation assignment limit value for an admin. */ - conversation_assignment_limit?: number; - /** The ticket assignment limit value for an admin. */ - ticket_assignment_limit?: number; - /** Details about the team whose assignment limit was changed. */ - team?: ActivityLogMetadata.Team; - /** The team assignment limit value (null if limit was removed). */ - team_assignment_limit?: number; - /** Indicates if the setting is enabled or disabled. */ - enabled?: boolean; - /** The ID of the impersonation consent. */ - consent_id?: number; - /** The timestamp when the impersonation consent expires. */ - expired_at?: string; - /** The state of settings or values before the change. Structure varies by activity type. */ - before?: Record; - /** The state of settings or values after the change. Structure varies by activity type. */ - after?: Record; -} - -export namespace ActivityLogMetadata { - /** - * Details about the team whose assignment limit was changed. - */ - export interface Team { - /** The ID of the team. */ - id?: number; - /** The name of the team. */ - name?: string; - } -} diff --git a/src/api/types/AddressableList.ts b/src/api/types/AddressableList.ts deleted file mode 100644 index cbda5a63..00000000 --- a/src/api/types/AddressableList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/AdminList.ts b/src/api/types/AdminList.ts deleted file mode 100644 index c504537d..00000000 --- a/src/api/types/AdminList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Admin | undefined)[]; -} diff --git a/src/api/types/AdminPriorityLevel.ts b/src/api/types/AdminPriorityLevel.ts deleted file mode 100644 index 1127dadf..00000000 --- a/src/api/types/AdminPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/AdminReplyConversationRequest.ts b/src/api/types/AdminReplyConversationRequest.ts deleted file mode 100644 index 36982c2d..00000000 --- a/src/api/types/AdminReplyConversationRequest.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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.ConversationAttachmentFiles[]; -} - -export namespace AdminReplyConversationRequest { - export const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; -} diff --git a/src/api/types/AdminReplyTicketRequest.ts b/src/api/types/AdminReplyTicketRequest.ts deleted file mode 100644 index 3e2ac1ed..00000000 --- a/src/api/types/AdminReplyTicketRequest.ts +++ /dev/null @@ -1,38 +0,0 @@ -// 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 const MessageType = { - Comment: "comment", - Note: "note", - QuickReply: "quick_reply", - } as const; - export type MessageType = (typeof MessageType)[keyof typeof MessageType]; - 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/types/AdminWithApp.ts b/src/api/types/AdminWithApp.ts deleted file mode 100644 index 8675a421..00000000 --- a/src/api/types/AdminWithApp.ts +++ /dev/null @@ -1,45 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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/types/App.ts b/src/api/types/App.ts deleted file mode 100644 index 67ce2d3c..00000000 --- a/src/api/types/App.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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/types/ArticleContent.ts b/src/api/types/ArticleContent.ts deleted file mode 100644 index bccb5af5..00000000 --- a/src/api/types/ArticleContent.ts +++ /dev/null @@ -1,34 +0,0 @@ -// 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?: "article_content"; - /** 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/ArticleList.ts b/src/api/types/ArticleList.ts deleted file mode 100644 index 02eb730b..00000000 --- a/src/api/types/ArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of articles for the App. - */ -export interface ArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: unknown; - /** A count of the total number of articles. */ - total_count?: number; - /** An array of Article objects */ - data?: Intercom.ArticleListItem[]; -} diff --git a/src/api/types/ArticleStatistics.ts b/src/api/types/ArticleStatistics.ts deleted file mode 100644 index 36ea843e..00000000 --- a/src/api/types/ArticleStatistics.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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/types/ArticleTranslatedContent.ts b/src/api/types/ArticleTranslatedContent.ts deleted file mode 100644 index 351d8148..00000000 --- a/src/api/types/ArticleTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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?: "article_translated_content"; - /** The content of the article in Arabic */ - ar?: Intercom.ArticleContent; - /** The content of the article in Bulgarian */ - bg?: Intercom.ArticleContent; - /** The content of the article in Bosnian */ - bs?: Intercom.ArticleContent; - /** The content of the article in Catalan */ - ca?: Intercom.ArticleContent; - /** The content of the article in Czech */ - cs?: Intercom.ArticleContent; - /** The content of the article in Danish */ - da?: Intercom.ArticleContent; - /** The content of the article in German */ - de?: Intercom.ArticleContent; - /** The content of the article in Greek */ - el?: Intercom.ArticleContent; - /** The content of the article in English */ - en?: Intercom.ArticleContent; - /** The content of the article in Spanish */ - es?: Intercom.ArticleContent; - /** The content of the article in Estonian */ - et?: Intercom.ArticleContent; - /** The content of the article in Finnish */ - fi?: Intercom.ArticleContent; - /** The content of the article in French */ - fr?: Intercom.ArticleContent; - /** The content of the article in Hebrew */ - he?: Intercom.ArticleContent; - /** The content of the article in Croatian */ - hr?: Intercom.ArticleContent; - /** The content of the article in Hungarian */ - hu?: Intercom.ArticleContent; - /** The content of the article in Indonesian */ - id?: Intercom.ArticleContent; - /** The content of the article in Italian */ - it?: Intercom.ArticleContent; - /** The content of the article in Japanese */ - ja?: Intercom.ArticleContent; - /** The content of the article in Korean */ - ko?: Intercom.ArticleContent; - /** The content of the article in Lithuanian */ - lt?: Intercom.ArticleContent; - /** The content of the article in Latvian */ - lv?: Intercom.ArticleContent; - /** The content of the article in Mongolian */ - mn?: Intercom.ArticleContent; - /** The content of the article in Norwegian */ - nb?: Intercom.ArticleContent; - /** The content of the article in Dutch */ - nl?: Intercom.ArticleContent; - /** The content of the article in Polish */ - pl?: Intercom.ArticleContent; - /** The content of the article in Portuguese (Portugal) */ - pt?: Intercom.ArticleContent; - /** The content of the article in Romanian */ - ro?: Intercom.ArticleContent; - /** The content of the article in Russian */ - ru?: Intercom.ArticleContent; - /** The content of the article in Slovenian */ - sl?: Intercom.ArticleContent; - /** The content of the article in Serbian */ - sr?: Intercom.ArticleContent; - /** The content of the article in Swedish */ - sv?: Intercom.ArticleContent; - /** The content of the article in Turkish */ - tr?: Intercom.ArticleContent; - /** The content of the article in Vietnamese */ - vi?: Intercom.ArticleContent; - /** The content of the article in Portuguese (Brazil) */ - "pt-BR"?: Intercom.ArticleContent; - /** The content of the article in Chinese (China) */ - "zh-CN"?: Intercom.ArticleContent; - /** The content of the article in Chinese (Taiwan) */ - "zh-TW"?: Intercom.ArticleContent; -} diff --git a/src/api/types/AssignConversationRequest.ts b/src/api/types/AssignConversationRequest.ts deleted file mode 100644 index 0e2e8ba8..00000000 --- a/src/api/types/AssignConversationRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 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 const Type = { - Admin: "admin", - Team: "team", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/AwayStatusReason.ts b/src/api/types/AwayStatusReason.ts deleted file mode 100644 index 01eaf720..00000000 --- a/src/api/types/AwayStatusReason.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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/types/CallList.ts b/src/api/types/CallList.ts deleted file mode 100644 index ab4b49a4..00000000 --- a/src/api/types/CallList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A paginated list of calls. - */ -export interface CallList { - /** String representing the object's type. Always has the value `list`. */ - type?: string; - /** A list of calls. */ - data?: Intercom.Call[]; - /** Total number of items available. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/CloseConversationRequest.ts b/src/api/types/CloseConversationRequest.ts deleted file mode 100644 index 0c75f0c3..00000000 --- a/src/api/types/CloseConversationRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/types/CollectionList.ts b/src/api/types/CollectionList.ts deleted file mode 100644 index d2c02975..00000000 --- a/src/api/types/CollectionList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of Collections for the App. - */ -export interface CollectionList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.OffsetPages; - /** A count of the total number of collections. */ - total_count?: number; - /** An array of collection objects */ - data?: Intercom.Collection[]; -} diff --git a/src/api/types/CompanyAttachedContacts.ts b/src/api/types/CompanyAttachedContacts.ts deleted file mode 100644 index 8725ffd9..00000000 --- a/src/api/types/CompanyAttachedContacts.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Contact Objects - */ -export interface CompanyAttachedContacts { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Contact Objects */ - data?: Intercom.Contact[]; - /** The total number of contacts */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/CompanyAttachedSegments.ts b/src/api/types/CompanyAttachedSegments.ts deleted file mode 100644 index aa6941ca..00000000 --- a/src/api/types/CompanyAttachedSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Segment Objects - */ -export interface CompanyAttachedSegments { - /** The type of object - `list` */ - type?: "list"; - /** An array containing Segment Objects */ - data?: Intercom.Segment[]; -} diff --git a/src/api/types/CompanyData.ts b/src/api/types/CompanyData.ts deleted file mode 100644 index 29d3a559..00000000 --- a/src/api/types/CompanyData.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/CompanyList.ts b/src/api/types/CompanyList.ts deleted file mode 100644 index 34851ae1..00000000 --- a/src/api/types/CompanyList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of companies for the App. - */ -export interface CompanyList { - /** The type of object - `list`. */ - type?: "list"; - pages?: Intercom.OffsetPages; - /** The total number of companies. */ - total_count?: number; - /** An array containing Company Objects. */ - data?: Intercom.Company[]; -} diff --git a/src/api/types/CompanyScroll.ts b/src/api/types/CompanyScroll.ts deleted file mode 100644 index 1ba47ea4..00000000 --- a/src/api/types/CompanyScroll.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Company[]; - pages?: Intercom.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/types/ContactArchived.ts b/src/api/types/ContactArchived.ts deleted file mode 100644 index 53e83824..00000000 --- a/src/api/types/ContactArchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * archived contact object - */ -export interface ContactArchived extends Intercom.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/types/ContactAttachedCompanies.ts b/src/api/types/ContactAttachedCompanies.ts deleted file mode 100644 index 6606054e..00000000 --- a/src/api/types/ContactAttachedCompanies.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * A list of Company Objects - */ -export interface ContactAttachedCompanies { - /** The type of object */ - type?: "list"; - /** An array containing Company Objects */ - companies?: Intercom.Company[]; - /** The total number of companies associated to this contact */ - total_count?: number; - pages?: Intercom.PagesLink; -} diff --git a/src/api/types/ContactBlocked.ts b/src/api/types/ContactBlocked.ts deleted file mode 100644 index 9c85baa7..00000000 --- a/src/api/types/ContactBlocked.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * blocked contact object - */ -export interface ContactBlocked extends Intercom.ContactReference { - /** Always true. */ - blocked?: boolean; -} diff --git a/src/api/types/ContactCompanies.ts b/src/api/types/ContactCompanies.ts deleted file mode 100644 index 8a3a13b0..00000000 --- a/src/api/types/ContactCompanies.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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/types/ContactDeleted.ts b/src/api/types/ContactDeleted.ts deleted file mode 100644 index 6b047f65..00000000 --- a/src/api/types/ContactDeleted.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * deleted contact object - */ -export interface ContactDeleted extends Intercom.ContactReference { - /** Whether the contact is deleted or not. */ - deleted?: boolean; -} diff --git a/src/api/types/ContactList.ts b/src/api/types/ContactList.ts deleted file mode 100644 index 2fc8ab69..00000000 --- a/src/api/types/ContactList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Contacts are your users in Intercom. - */ -export interface ContactList { - /** Always list */ - type?: "list"; - /** The list of contact objects */ - data?: Intercom.Contact[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/ContactLocation.ts b/src/api/types/ContactLocation.ts deleted file mode 100644 index 73f32530..00000000 --- a/src/api/types/ContactLocation.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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/types/ContactNotes.ts b/src/api/types/ContactNotes.ts deleted file mode 100644 index 77a34b6f..00000000 --- a/src/api/types/ContactNotes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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/types/ContactReference.ts b/src/api/types/ContactReference.ts deleted file mode 100644 index 6ff6080e..00000000 --- a/src/api/types/ContactReference.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/ContactReplyBaseRequest.ts b/src/api/types/ContactReplyBaseRequest.ts deleted file mode 100644 index e6ebd102..00000000 --- a/src/api/types/ContactReplyBaseRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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/types/ContactReplyConversationRequest.ts b/src/api/types/ContactReplyConversationRequest.ts deleted file mode 100644 index c0f18e11..00000000 --- a/src/api/types/ContactReplyConversationRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ContactReplyConversationRequest = - | Intercom.ContactReplyIntercomUserIdRequest - | Intercom.ContactReplyEmailRequest - | Intercom.ContactReplyUserIdRequest; diff --git a/src/api/types/ContactReplyEmailRequest.ts b/src/api/types/ContactReplyEmailRequest.ts deleted file mode 100644 index 3af33d96..00000000 --- a/src/api/types/ContactReplyEmailRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyEmailRequest extends Intercom.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; - /** A list of files that will be added as attachments. */ - attachment_files?: Intercom.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactReplyIntercomUserIdRequest.ts b/src/api/types/ContactReplyIntercomUserIdRequest.ts deleted file mode 100644 index 4a3b3f1b..00000000 --- a/src/api/types/ContactReplyIntercomUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyIntercomUserIdRequest extends Intercom.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.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactReplyTicketEmailRequest.ts b/src/api/types/ContactReplyTicketEmailRequest.ts deleted file mode 100644 index 8baf8758..00000000 --- a/src/api/types/ContactReplyTicketEmailRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `email` - */ -export interface ContactReplyTicketEmailRequest extends Intercom.ContactReplyBaseRequest { - /** The email you have defined for the user. */ - email: string; -} diff --git a/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts b/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts deleted file mode 100644 index 712a6dfc..00000000 --- a/src/api/types/ContactReplyTicketIntercomUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `intercom_user_id` - */ -export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The identifier for the contact as given by Intercom. */ - intercom_user_id: string; -} diff --git a/src/api/types/ContactReplyTicketRequest.ts b/src/api/types/ContactReplyTicketRequest.ts deleted file mode 100644 index a8deae5d..00000000 --- a/src/api/types/ContactReplyTicketRequest.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ContactReplyTicketRequest = - | Intercom.ContactReplyTicketIntercomUserIdRequest - | Intercom.ContactReplyTicketUserIdRequest - | Intercom.ContactReplyTicketEmailRequest; diff --git a/src/api/types/ContactReplyTicketUserIdRequest.ts b/src/api/types/ContactReplyTicketUserIdRequest.ts deleted file mode 100644 index d754bd17..00000000 --- a/src/api/types/ContactReplyTicketUserIdRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyTicketUserIdRequest extends Intercom.ContactReplyBaseRequest { - /** The external_id you have defined for the contact. */ - user_id: string; -} diff --git a/src/api/types/ContactReplyUserIdRequest.ts b/src/api/types/ContactReplyUserIdRequest.ts deleted file mode 100644 index c043f3cc..00000000 --- a/src/api/types/ContactReplyUserIdRequest.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Payload of the request to reply on behalf of a contact using their `user_id` - */ -export interface ContactReplyUserIdRequest extends Intercom.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.ConversationAttachmentFiles[]; -} diff --git a/src/api/types/ContactSegments.ts b/src/api/types/ContactSegments.ts deleted file mode 100644 index 5099c19d..00000000 --- a/src/api/types/ContactSegments.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Segment[]; -} diff --git a/src/api/types/ContactSocialProfiles.ts b/src/api/types/ContactSocialProfiles.ts deleted file mode 100644 index c61e7c62..00000000 --- a/src/api/types/ContactSocialProfiles.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * An object containing social profiles that a contact has. - */ -export interface ContactSocialProfiles { - /** A list of social profiles objects associated with the contact. */ - data?: Intercom.SocialProfile[]; -} diff --git a/src/api/types/ContactSubscriptionTypes.ts b/src/api/types/ContactSubscriptionTypes.ts deleted file mode 100644 index 358f4604..00000000 --- a/src/api/types/ContactSubscriptionTypes.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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/types/ContactTags.ts b/src/api/types/ContactTags.ts deleted file mode 100644 index 90b8cc0f..00000000 --- a/src/api/types/ContactTags.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.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/types/ContactUnarchived.ts b/src/api/types/ContactUnarchived.ts deleted file mode 100644 index 5c84ff30..00000000 --- a/src/api/types/ContactUnarchived.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * unarchived contact object - */ -export interface ContactUnarchived extends Intercom.ContactReference { - /** Whether the contact is archived or not. */ - archived?: boolean; -} diff --git a/src/api/types/ContentSourcesList.ts b/src/api/types/ContentSourcesList.ts deleted file mode 100644 index 4af840d0..00000000 --- a/src/api/types/ContentSourcesList.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -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.ContentSource[]; -} diff --git a/src/api/types/ConversationAttachmentFiles.ts b/src/api/types/ConversationAttachmentFiles.ts deleted file mode 100644 index f1a0b3e5..00000000 --- a/src/api/types/ConversationAttachmentFiles.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/ConversationAttributeUpdatedByAdmin.ts b/src/api/types/ConversationAttributeUpdatedByAdmin.ts deleted file mode 100644 index b44c2202..00000000 --- a/src/api/types/ConversationAttributeUpdatedByAdmin.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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/types/ConversationAttributeUpdatedByWorkflow.ts b/src/api/types/ConversationAttributeUpdatedByWorkflow.ts deleted file mode 100644 index e9e75f32..00000000 --- a/src/api/types/ConversationAttributeUpdatedByWorkflow.ts +++ /dev/null @@ -1,27 +0,0 @@ -// 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/types/ConversationContacts.ts b/src/api/types/ConversationContacts.ts deleted file mode 100644 index 860cd318..00000000 --- a/src/api/types/ConversationContacts.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.ContactReference[]; -} diff --git a/src/api/types/ConversationDeleted.ts b/src/api/types/ConversationDeleted.ts deleted file mode 100644 index e61823b9..00000000 --- a/src/api/types/ConversationDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/ConversationFirstContactReply.ts b/src/api/types/ConversationFirstContactReply.ts deleted file mode 100644 index 2085bd1e..00000000 --- a/src/api/types/ConversationFirstContactReply.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/ConversationList.ts b/src/api/types/ConversationList.ts deleted file mode 100644 index 4d0c74f3..00000000 --- a/src/api/types/ConversationList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Conversation[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/ConversationPart.ts b/src/api/types/ConversationPart.ts deleted file mode 100644 index 2182ec66..00000000 --- a/src/api/types/ConversationPart.ts +++ /dev/null @@ -1,51 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Reference; - author?: Intercom.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.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.EmailMessageMetadata; - metadata?: Intercom.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.TagBasic[]; - event_details?: Intercom.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 const State = { - Open: "open", - Closed: "closed", - Snoozed: "snoozed", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/ConversationPartAuthor.ts b/src/api/types/ConversationPartAuthor.ts deleted file mode 100644 index 3a17d751..00000000 --- a/src/api/types/ConversationPartAuthor.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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/types/ConversationPartMetadata.ts b/src/api/types/ConversationPartMetadata.ts deleted file mode 100644 index 34c17f40..00000000 --- a/src/api/types/ConversationPartMetadata.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.QuickReplyOption { - /** The translations for the quick reply option. */ - translations?: Record; - } - } -} diff --git a/src/api/types/ConversationParts.ts b/src/api/types/ConversationParts.ts deleted file mode 100644 index ba6730f6..00000000 --- a/src/api/types/ConversationParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.ConversationPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/types/ConversationRating.ts b/src/api/types/ConversationRating.ts deleted file mode 100644 index 1ba83dbb..00000000 --- a/src/api/types/ConversationRating.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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; - /** The time the rating was last updated. */ - updated_at?: number; - contact?: Intercom.ContactReference; - teammate?: Intercom.Reference; -} diff --git a/src/api/types/ConversationResponseTime.ts b/src/api/types/ConversationResponseTime.ts deleted file mode 100644 index 8c503679..00000000 --- a/src/api/types/ConversationResponseTime.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/ConversationSource.ts b/src/api/types/ConversationSource.ts deleted file mode 100644 index 960f667c..00000000 --- a/src/api/types/ConversationSource.ts +++ /dev/null @@ -1,43 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.ConversationPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.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 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; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/ConversationStatistics.ts b/src/api/types/ConversationStatistics.ts deleted file mode 100644 index 999c99f5..00000000 --- a/src/api/types/ConversationStatistics.ts +++ /dev/null @@ -1,55 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.ConversationResponseTime[]; - /** An array of conversation response time objects within office hours */ - assigned_team_first_response_time_in_office_hours?: Intercom.ConversationResponseTime[]; - /** Time from conversation assignment to conversation close in seconds. */ - handling_time?: number; - /** Adjusted handling time for conversation in seconds. This is the active handling time excluding idle periods when teammates are not actively working on the conversation. */ - adjusted_handling_time?: number; -} diff --git a/src/api/types/ConversationTeammates.ts b/src/api/types/ConversationTeammates.ts deleted file mode 100644 index 4f278e45..00000000 --- a/src/api/types/ConversationTeammates.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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: "admin.list"; - /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ - admins: Intercom.Reference[]; -} diff --git a/src/api/types/CreateArticleRequest.ts b/src/api/types/CreateArticleRequest.ts deleted file mode 100644 index 432c43aa..00000000 --- a/src/api/types/CreateArticleRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create an Article - */ -export interface CreateArticleRequest { - /** 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?: CreateArticleRequest.State; - /** The id of the article's parent collection or section. An article without this field stands alone. */ - parent_id?: number; - /** The type of parent, which can either be a `collection` or `section`. */ - parent_type?: CreateArticleRequest.ParentType; - translated_content?: Intercom.ArticleTranslatedContent; -} - -export namespace CreateArticleRequest { - /** 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 const State = { - Published: "published", - Draft: "draft", - } as const; - export type State = (typeof State)[keyof typeof State]; - /** The type of parent, which can either be a `collection` or `section`. */ - export const ParentType = { - Collection: "collection", - Section: "section", - } as const; - export type ParentType = (typeof ParentType)[keyof typeof ParentType]; -} diff --git a/src/api/types/CreateContactRequest.ts b/src/api/types/CreateContactRequest.ts deleted file mode 100644 index 4067737b..00000000 --- a/src/api/types/CreateContactRequest.ts +++ /dev/null @@ -1,39 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Payload to create a contact - */ -export type CreateContactRequest = - | { - email: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - } - | { - external_id: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - } - | { - role: string; - phone?: string | undefined; - name?: string | undefined; - avatar?: string | undefined; - signed_up_at?: number | undefined; - last_seen_at?: number | undefined; - owner_id?: number | undefined; - unsubscribed_from_emails?: boolean | undefined; - custom_attributes?: Record | undefined; - }; diff --git a/src/api/types/CreateContactRequestTwo.ts b/src/api/types/CreateContactRequestTwo.ts deleted file mode 100644 index 06133b6b..00000000 --- a/src/api/types/CreateContactRequestTwo.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CreateContactRequestTwo = unknown; diff --git a/src/api/types/CreateDataAttributeRequest.ts b/src/api/types/CreateDataAttributeRequest.ts deleted file mode 100644 index e2abd5d2..00000000 --- a/src/api/types/CreateDataAttributeRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataAttributeRequest = - | { - data_type?: "options" | undefined; - options: { - value?: string | undefined; - }[]; - } - | { - data_type?: ("string" | "integer" | "float" | "boolean" | "datetime" | "date") | undefined; - }; diff --git a/src/api/types/CreateDataEventRequest.ts b/src/api/types/CreateDataEventRequest.ts deleted file mode 100644 index b0502eab..00000000 --- a/src/api/types/CreateDataEventRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type CreateDataEventRequest = - | { - id: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - } - | { - user_id: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - } - | { - email: string; - event_name: string; - created_at: number; - metadata?: Record | undefined; - }; diff --git a/src/api/types/CreateDataEventRequestTwo.ts b/src/api/types/CreateDataEventRequestTwo.ts deleted file mode 100644 index d4d0d15e..00000000 --- a/src/api/types/CreateDataEventRequestTwo.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type CreateDataEventRequestTwo = unknown; diff --git a/src/api/types/CreateInternalArticleRequest.ts b/src/api/types/CreateInternalArticleRequest.ts deleted file mode 100644 index f971e918..00000000 --- a/src/api/types/CreateInternalArticleRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create an Internal Article - */ -export interface CreateInternalArticleRequest { - /** The title of the article. */ - title: string; - /** The content of the article. */ - body?: string; - /** The id of the author of the article. */ - author_id: number; - /** The id of the owner of the article. */ - owner_id: number; -} diff --git a/src/api/types/CreateMessageRequest.ts b/src/api/types/CreateMessageRequest.ts deleted file mode 100644 index 2e3bc5fb..00000000 --- a/src/api/types/CreateMessageRequest.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create a message - */ -export type CreateMessageRequest = Intercom.CreateMessageRequest.Email | Intercom.CreateMessageRequest.Inapp; - -export namespace CreateMessageRequest { - export interface Email { - message_type: "email"; - /** The title of the email. */ - subject: string; - /** The content of the message. HTML and plaintext are supported. */ - body: string; - /** The style of the outgoing message. Possible values `plain` or `personal`. */ - template: string; - /** The sender of the message. If not provided, the default sender will be used. */ - from: CreateMessageRequestWithEmail.From; - /** The sender of the message. If not provided, the default sender will be used. */ - to: CreateMessageRequestWithEmail.To; - /** The time the message was created. If not provided, the current time will be used. */ - created_at?: number; - /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ - create_conversation_without_contact_reply?: boolean; - } - - export namespace CreateMessageRequestWithEmail { - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface From { - /** Always `admin`. */ - type: "admin"; - /** The identifier for the admin which is given by Intercom. */ - id: number; - } - - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface To { - /** The role associated to the contact - `user` or `lead`. */ - type: To.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; - } - - export namespace To { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } - - export interface Inapp { - message_type: "inapp"; - /** The title of the email. */ - subject?: string; - /** The content of the message. HTML and plaintext are supported. */ - body: string; - /** The style of the outgoing message. Possible values `plain` or `personal`. */ - template?: string; - /** The sender of the message. If not provided, the default sender will be used. */ - from: CreateMessageRequestWithInapp.From; - /** The sender of the message. If not provided, the default sender will be used. */ - to: CreateMessageRequestWithInapp.To; - /** The time the message was created. If not provided, the current time will be used. */ - created_at?: number; - /** Whether a conversation should be opened in the inbox for the message without the contact replying. Defaults to false if not provided. */ - create_conversation_without_contact_reply?: boolean; - } - - export namespace CreateMessageRequestWithInapp { - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface From { - /** Always `admin`. */ - type: "admin"; - /** The identifier for the admin which is given by Intercom. */ - id: number; - } - - /** - * The sender of the message. If not provided, the default sender will be used. - */ - export interface To { - /** The role associated to the contact - `user` or `lead`. */ - type: To.Type; - /** The identifier for the contact which is given by Intercom. */ - id: string; - } - - export namespace To { - /** The role associated to the contact - `user` or `lead`. */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - } - } -} diff --git a/src/api/types/CreateOrUpdateCompanyRequest.ts b/src/api/types/CreateOrUpdateCompanyRequest.ts deleted file mode 100644 index 136693c2..00000000 --- a/src/api/types/CreateOrUpdateCompanyRequest.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can create or update a Company - */ -export interface CreateOrUpdateCompanyRequest { - /** The name of the Company */ - name?: string; - /** The company id you have defined for the company. Can't be updated */ - company_id?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** The time the company was created by you. */ - remote_created_at?: number; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/types/CreateOrUpdateTagRequest.ts b/src/api/types/CreateOrUpdateTagRequest.ts deleted file mode 100644 index 7dfd1b3f..00000000 --- a/src/api/types/CreateOrUpdateTagRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/CreatePhoneSwitchRequest.ts b/src/api/types/CreatePhoneSwitchRequest.ts deleted file mode 100644 index aae47b79..00000000 --- a/src/api/types/CreatePhoneSwitchRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * You can create an phone switch - */ -export interface CreatePhoneSwitchRequest { - /** Phone number in E.164 format, that will receive the SMS to continue the conversation in the Messenger. */ - phone: string; - custom_attributes?: Intercom.CustomAttributes; -} diff --git a/src/api/types/CreateTicketReplyWithCommentRequest.ts b/src/api/types/CreateTicketReplyWithCommentRequest.ts deleted file mode 100644 index 31d1cccc..00000000 --- a/src/api/types/CreateTicketReplyWithCommentRequest.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type CreateTicketReplyWithCommentRequest = Intercom.ContactReplyTicketRequest | Intercom.AdminReplyTicketRequest; diff --git a/src/api/types/CreateTicketRequestBody.ts b/src/api/types/CreateTicketRequestBody.ts deleted file mode 100644 index 9ec9fb5c..00000000 --- a/src/api/types/CreateTicketRequestBody.ts +++ /dev/null @@ -1,48 +0,0 @@ -// 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/types/CreateTicketTypeRequest.ts b/src/api/types/CreateTicketTypeRequest.ts deleted file mode 100644 index eebc72da..00000000 --- a/src/api/types/CreateTicketTypeRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * The request payload for creating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) - */ -export interface CreateTicketTypeRequest { - /** The name of the ticket type. */ - name: string; - /** The description of the ticket type. */ - description?: string; - /** Category of the Ticket Type. */ - category?: CreateTicketTypeRequest.Category; - /** The icon of the ticket type. */ - icon?: string; - /** 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 CreateTicketTypeRequest { - /** Category of the Ticket Type. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/types/CursorPages.ts b/src/api/types/CursorPages.ts deleted file mode 100644 index 4245c670..00000000 --- a/src/api/types/CursorPages.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.StartingAfterPaging; - /** Number of results per page */ - per_page?: number; - /** Total number of pages */ - total_pages?: number; -} diff --git a/src/api/types/CustomActionFinished.ts b/src/api/types/CustomActionFinished.ts deleted file mode 100644 index 54471392..00000000 --- a/src/api/types/CustomActionFinished.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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 const Result = { - Success: "success", - Failed: "failed", - } as const; - export type Result = (typeof Result)[keyof typeof Result]; - } -} diff --git a/src/api/types/CustomActionStarted.ts b/src/api/types/CustomActionStarted.ts deleted file mode 100644 index 18114f6c..00000000 --- a/src/api/types/CustomActionStarted.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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/types/CustomAttributes.ts b/src/api/types/CustomAttributes.ts deleted file mode 100644 index 6fd00ee3..00000000 --- a/src/api/types/CustomAttributes.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Custom data set for this data. - */ -export type CustomAttributes = Record; - -export namespace CustomAttributes { - export type Value = string | number | Intercom.Datetime | Intercom.CustomObjectInstanceList; -} diff --git a/src/api/types/CustomChannelAttribute.ts b/src/api/types/CustomChannelAttribute.ts deleted file mode 100644 index 9afa1dd6..00000000 --- a/src/api/types/CustomChannelAttribute.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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/types/CustomChannelBaseEvent.ts b/src/api/types/CustomChannelBaseEvent.ts deleted file mode 100644 index dcf9e00e..00000000 --- a/src/api/types/CustomChannelBaseEvent.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export interface CustomChannelBaseEvent { - /** Unique identifier for the event. */ - event_id: string; - /** Identifier for the conversation in your application. */ - external_conversation_id: string; - contact: Intercom.CustomChannelContact; -} diff --git a/src/api/types/CustomChannelContact.ts b/src/api/types/CustomChannelContact.ts deleted file mode 100644 index 7d11a83c..00000000 --- a/src/api/types/CustomChannelContact.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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. Required for user type. */ - name?: string; - /** Email address of the contact. Required for user type. */ - email?: string; -} - -export namespace CustomChannelContact { - /** Type of contact, must be "user" or "lead". */ - export const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/CustomChannelNotificationResponse.ts b/src/api/types/CustomChannelNotificationResponse.ts deleted file mode 100644 index 238b883d..00000000 --- a/src/api/types/CustomChannelNotificationResponse.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/types/CustomObjectInstanceDeleted.ts b/src/api/types/CustomObjectInstanceDeleted.ts deleted file mode 100644 index 4c14eba9..00000000 --- a/src/api/types/CustomObjectInstanceDeleted.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/CustomObjectInstanceList.ts b/src/api/types/CustomObjectInstanceList.ts deleted file mode 100644 index f537ed2d..00000000 --- a/src/api/types/CustomObjectInstanceList.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.CustomObjectInstance | undefined)[]; -} diff --git a/src/api/types/CustomerRequest.ts b/src/api/types/CustomerRequest.ts deleted file mode 100644 index d86d11c7..00000000 --- a/src/api/types/CustomerRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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/types/DataAttributeList.ts b/src/api/types/DataAttributeList.ts deleted file mode 100644 index 6fb01c20..00000000 --- a/src/api/types/DataAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.DataAttribute[]; -} diff --git a/src/api/types/DataEventList.ts b/src/api/types/DataEventList.ts deleted file mode 100644 index 2a68082a..00000000 --- a/src/api/types/DataEventList.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.DataEvent[]; - /** Pagination */ - pages?: DataEventList.Pages; -} - -export namespace DataEventList { - /** - * Pagination - */ - export interface Pages { - next?: string; - since?: string; - } -} diff --git a/src/api/types/DataEventSummary.ts b/src/api/types/DataEventSummary.ts deleted file mode 100644 index e2791b1f..00000000 --- a/src/api/types/DataEventSummary.ts +++ /dev/null @@ -1,19 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.DataEventSummaryItem | undefined)[]; -} diff --git a/src/api/types/DataEventSummaryItem.ts b/src/api/types/DataEventSummaryItem.ts deleted file mode 100644 index 9f0d9192..00000000 --- a/src/api/types/DataEventSummaryItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// 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/types/DataExportCsv.ts b/src/api/types/DataExportCsv.ts deleted file mode 100644 index 8c268f7e..00000000 --- a/src/api/types/DataExportCsv.ts +++ /dev/null @@ -1,59 +0,0 @@ -// 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/types/Datetime.ts b/src/api/types/Datetime.ts deleted file mode 100644 index 63964732..00000000 --- a/src/api/types/Datetime.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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/types/DeletedArticleObject.ts b/src/api/types/DeletedArticleObject.ts deleted file mode 100644 index 5667114c..00000000 --- a/src/api/types/DeletedArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/DeletedCollectionObject.ts b/src/api/types/DeletedCollectionObject.ts deleted file mode 100644 index 4d03d936..00000000 --- a/src/api/types/DeletedCollectionObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/DeletedCompanyObject.ts b/src/api/types/DeletedCompanyObject.ts deleted file mode 100644 index b5ee6cf6..00000000 --- a/src/api/types/DeletedCompanyObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/DeletedInternalArticleObject.ts b/src/api/types/DeletedInternalArticleObject.ts deleted file mode 100644 index 47d5060b..00000000 --- a/src/api/types/DeletedInternalArticleObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Response returned when an object is deleted - */ -export interface DeletedInternalArticleObject { - /** The unique identifier for the internal article which you provided in the URL. */ - id?: string; - /** The type of object which was deleted. - internal_article */ - object?: "internal_article"; - /** Whether the internal article was deleted successfully or not. */ - deleted?: boolean; -} diff --git a/src/api/types/DeletedObject.ts b/src/api/types/DeletedObject.ts deleted file mode 100644 index a22b393b..00000000 --- a/src/api/types/DeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/EmailAddressHeader.ts b/src/api/types/EmailAddressHeader.ts deleted file mode 100644 index 7e8d234d..00000000 --- a/src/api/types/EmailAddressHeader.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/EmailMessageMetadata.ts b/src/api/types/EmailMessageMetadata.ts deleted file mode 100644 index 815571b7..00000000 --- a/src/api/types/EmailMessageMetadata.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.EmailAddressHeader[]; -} diff --git a/src/api/types/Error_.ts b/src/api/types/Error_.ts deleted file mode 100644 index 5a4a39f0..00000000 --- a/src/api/types/Error_.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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: "error.list"; - /** */ - 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/types/EventDetails.ts b/src/api/types/EventDetails.ts deleted file mode 100644 index 6db41ca1..00000000 --- a/src/api/types/EventDetails.ts +++ /dev/null @@ -1,10 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type EventDetails = - | Intercom.ConversationAttributeUpdatedByWorkflow - | Intercom.ConversationAttributeUpdatedByAdmin - | Intercom.CustomActionStarted - | Intercom.CustomActionFinished - | Intercom.OperatorWorkflowEvent; diff --git a/src/api/types/FileAttribute.ts b/src/api/types/FileAttribute.ts deleted file mode 100644 index b8fab036..00000000 --- a/src/api/types/FileAttribute.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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/types/GroupContent.ts b/src/api/types/GroupContent.ts deleted file mode 100644 index 68c5b320..00000000 --- a/src/api/types/GroupContent.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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?: "group_content"; - /** 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/types/GroupTranslatedContent.ts b/src/api/types/GroupTranslatedContent.ts deleted file mode 100644 index 51302ff2..00000000 --- a/src/api/types/GroupTranslatedContent.ts +++ /dev/null @@ -1,85 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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?: "group_translated_content"; - /** The content of the group in Arabic */ - ar?: Intercom.GroupContent; - /** The content of the group in Bulgarian */ - bg?: Intercom.GroupContent; - /** The content of the group in Bosnian */ - bs?: Intercom.GroupContent; - /** The content of the group in Catalan */ - ca?: Intercom.GroupContent; - /** The content of the group in Czech */ - cs?: Intercom.GroupContent; - /** The content of the group in Danish */ - da?: Intercom.GroupContent; - /** The content of the group in German */ - de?: Intercom.GroupContent; - /** The content of the group in Greek */ - el?: Intercom.GroupContent; - /** The content of the group in English */ - en?: Intercom.GroupContent; - /** The content of the group in Spanish */ - es?: Intercom.GroupContent; - /** The content of the group in Estonian */ - et?: Intercom.GroupContent; - /** The content of the group in Finnish */ - fi?: Intercom.GroupContent; - /** The content of the group in French */ - fr?: Intercom.GroupContent; - /** The content of the group in Hebrew */ - he?: Intercom.GroupContent; - /** The content of the group in Croatian */ - hr?: Intercom.GroupContent; - /** The content of the group in Hungarian */ - hu?: Intercom.GroupContent; - /** The content of the group in Indonesian */ - id?: Intercom.GroupContent; - /** The content of the group in Italian */ - it?: Intercom.GroupContent; - /** The content of the group in Japanese */ - ja?: Intercom.GroupContent; - /** The content of the group in Korean */ - ko?: Intercom.GroupContent; - /** The content of the group in Lithuanian */ - lt?: Intercom.GroupContent; - /** The content of the group in Latvian */ - lv?: Intercom.GroupContent; - /** The content of the group in Mongolian */ - mn?: Intercom.GroupContent; - /** The content of the group in Norwegian */ - nb?: Intercom.GroupContent; - /** The content of the group in Dutch */ - nl?: Intercom.GroupContent; - /** The content of the group in Polish */ - pl?: Intercom.GroupContent; - /** The content of the group in Portuguese (Portugal) */ - pt?: Intercom.GroupContent; - /** The content of the group in Romanian */ - ro?: Intercom.GroupContent; - /** The content of the group in Russian */ - ru?: Intercom.GroupContent; - /** The content of the group in Slovenian */ - sl?: Intercom.GroupContent; - /** The content of the group in Serbian */ - sr?: Intercom.GroupContent; - /** The content of the group in Swedish */ - sv?: Intercom.GroupContent; - /** The content of the group in Turkish */ - tr?: Intercom.GroupContent; - /** The content of the group in Vietnamese */ - vi?: Intercom.GroupContent; - /** The content of the group in Portuguese (Brazil) */ - "pt-BR"?: Intercom.GroupContent; - /** The content of the group in Chinese (China) */ - "zh-CN"?: Intercom.GroupContent; - /** The content of the group in Chinese (Taiwan) */ - "zh-TW"?: Intercom.GroupContent; -} diff --git a/src/api/types/InternalArticleList.ts b/src/api/types/InternalArticleList.ts deleted file mode 100644 index 8de68a0a..00000000 --- a/src/api/types/InternalArticleList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * This will return a list of internal articles for the App. - */ -export interface InternalArticleList { - /** The type of the object - `list`. */ - type?: "list"; - pages?: Intercom.CursorPages; - /** A count of the total number of internal articles. */ - total_count?: number; - /** An array of Internal Article objects */ - data?: Intercom.InternalArticleListItem[]; -} diff --git a/src/api/types/IpAllowlist.ts b/src/api/types/IpAllowlist.ts deleted file mode 100644 index 27a5b011..00000000 --- a/src/api/types/IpAllowlist.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * IP allowlist settings for the workspace. - */ -export interface IpAllowlist { - /** String representing the object's type. Always has the value `ip_allowlist`. */ - type?: string; - /** Whether the IP allowlist is enabled for the workspace. */ - enabled?: boolean; - /** - * List of allowed IP addresses and/or IP ranges in CIDR notation. - * Examples: - * - Single IP: `192.168.0.1` - * - IP range: `192.168.0.1/24` (allows 192.168.0.0 - 192.168.0.255) - */ - ip_allowlist?: string[]; -} diff --git a/src/api/types/LinkedObject.ts b/src/api/types/LinkedObject.ts deleted file mode 100644 index 27fe77b5..00000000 --- a/src/api/types/LinkedObject.ts +++ /dev/null @@ -1,29 +0,0 @@ -// 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?: LinkedObject.Category; -} - -export namespace LinkedObject { - /** ticket or conversation */ - export const Type = { - Ticket: "ticket", - Conversation: "conversation", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; - /** Category of the Linked Ticket Object. */ - export const Category = { - Customer: "Customer", - BackOffice: "Back-office", - Tracker: "Tracker", - } as const; - export type Category = (typeof Category)[keyof typeof Category]; -} diff --git a/src/api/types/LinkedObjectList.ts b/src/api/types/LinkedObjectList.ts deleted file mode 100644 index 3443c217..00000000 --- a/src/api/types/LinkedObjectList.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.LinkedObject[]; -} diff --git a/src/api/types/Metadata.ts b/src/api/types/Metadata.ts deleted file mode 100644 index 8d9ca56e..00000000 --- a/src/api/types/Metadata.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type Metadata = Intercom.unstable.ConversationPartMetadata; diff --git a/src/api/types/MultipleFilterSearchRequest.ts b/src/api/types/MultipleFilterSearchRequest.ts deleted file mode 100644 index 400b4119..00000000 --- a/src/api/types/MultipleFilterSearchRequest.ts +++ /dev/null @@ -1,28 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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 const Operator = { - And: "AND", - Or: "OR", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - export type Value = - /** - * Add mutiple filters. */ - | Intercom.MultipleFilterSearchRequest[] - /** - * Add a single filter field. */ - | Intercom.SingleFilterSearchRequest[]; -} diff --git a/src/api/types/NewsItemRequest.ts b/src/api/types/NewsItemRequest.ts deleted file mode 100644 index 89a1a61d..00000000 --- a/src/api/types/NewsItemRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.NewsfeedAssignment[]; -} - -export namespace NewsItemRequest { - /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ - export const State = { - Draft: "draft", - Live: "live", - } as const; - export type State = (typeof State)[keyof typeof State]; -} diff --git a/src/api/types/NotFoundErrorBody.ts b/src/api/types/NotFoundErrorBody.ts deleted file mode 100644 index de9109f3..00000000 --- a/src/api/types/NotFoundErrorBody.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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/types/NoteList.ts b/src/api/types/NoteList.ts deleted file mode 100644 index 5090713e..00000000 --- a/src/api/types/NoteList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Note[]; - /** A count of the total number of notes. */ - total_count?: number; -} diff --git a/src/api/types/OffsetPages.ts b/src/api/types/OffsetPages.ts deleted file mode 100644 index 7118e2df..00000000 --- a/src/api/types/OffsetPages.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface OffsetPages { - /** the type of object `offset_pages` */ - type: "offset_pages"; - /** The current offset */ - page?: number; - next?: string; - /** Number of results per page */ - per_page?: number; - /** Total number of pages */ - total_pages?: number; -} diff --git a/src/api/types/OpenConversationRequest.ts b/src/api/types/OpenConversationRequest.ts deleted file mode 100644 index b3e63714..00000000 --- a/src/api/types/OpenConversationRequest.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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/types/OperatorWorkflowEvent.ts b/src/api/types/OperatorWorkflowEvent.ts deleted file mode 100644 index df8629d3..00000000 --- a/src/api/types/OperatorWorkflowEvent.ts +++ /dev/null @@ -1,23 +0,0 @@ -// 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/types/PagesLink.ts b/src/api/types/PagesLink.ts deleted file mode 100644 index 59d698ff..00000000 --- a/src/api/types/PagesLink.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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/types/PaginatedResponse.ts b/src/api/types/PaginatedResponse.ts deleted file mode 100644 index 320b646d..00000000 --- a/src/api/types/PaginatedResponse.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Paginated Response - */ -export interface PaginatedResponse { - /** The type of object */ - type?: PaginatedResponse.Type; - pages?: Intercom.CursorPages; - /** A count of the total number of objects. */ - total_count?: number; - /** An array of Objects */ - data?: Intercom.PaginatedResponseDataItem[]; -} - -export namespace PaginatedResponse { - /** The type of object */ - export const Type = { - List: "list", - ConversationList: "conversation.list", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/PaginatedResponseDataItem.ts b/src/api/types/PaginatedResponseDataItem.ts deleted file mode 100644 index 4aec3d71..00000000 --- a/src/api/types/PaginatedResponseDataItem.ts +++ /dev/null @@ -1,17 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type PaginatedResponseDataItem = - | Intercom.PaginatedResponseDataItem.NewsItem - | Intercom.PaginatedResponseDataItem.Newsfeed; - -export namespace PaginatedResponseDataItem { - export interface NewsItem extends Intercom.NewsItem { - type: "news-item"; - } - - export interface Newsfeed extends Intercom.Newsfeed { - type: "newsfeed"; - } -} diff --git a/src/api/types/PartAttachment.ts b/src/api/types/PartAttachment.ts deleted file mode 100644 index 3c01b778..00000000 --- a/src/api/types/PartAttachment.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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/types/PhoneSwitch.ts b/src/api/types/PhoneSwitch.ts deleted file mode 100644 index 5fbeb892..00000000 --- a/src/api/types/PhoneSwitch.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/QuickReplyOption.ts b/src/api/types/QuickReplyOption.ts deleted file mode 100644 index 8de2d400..00000000 --- a/src/api/types/QuickReplyOption.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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/types/Recipient.ts b/src/api/types/Recipient.ts deleted file mode 100644 index 194d11d0..00000000 --- a/src/api/types/Recipient.ts +++ /dev/null @@ -1,20 +0,0 @@ -// 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 const Type = { - User: "user", - Lead: "lead", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/RedactConversationRequest.ts b/src/api/types/RedactConversationRequest.ts deleted file mode 100644 index 08d784b4..00000000 --- a/src/api/types/RedactConversationRequest.ts +++ /dev/null @@ -1,29 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type RedactConversationRequest = - /** - * Payload of the request to redact a conversation part */ - | Intercom.RedactConversationRequest.ConversationPart - /** - * Payload of the request to redact a conversation source */ - | Intercom.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/types/Reference.ts b/src/api/types/Reference.ts deleted file mode 100644 index 7c9c82a3..00000000 --- a/src/api/types/Reference.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/ReplyConversationRequest.ts b/src/api/types/ReplyConversationRequest.ts deleted file mode 100644 index 113e344e..00000000 --- a/src/api/types/ReplyConversationRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -export type ReplyConversationRequest = - | Intercom.ContactReplyConversationRequest - | Intercom.AdminReplyConversationRequest; diff --git a/src/api/types/SearchRequest.ts b/src/api/types/SearchRequest.ts deleted file mode 100644 index be8ae5af..00000000 --- a/src/api/types/SearchRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * Search using Intercoms Search APIs. - */ -export interface SearchRequest { - query: SearchRequest.Query; - pagination?: Intercom.StartingAfterPaging; -} - -export namespace SearchRequest { - export type Query = Intercom.SingleFilterSearchRequest | Intercom.MultipleFilterSearchRequest; -} diff --git a/src/api/types/SegmentList.ts b/src/api/types/SegmentList.ts deleted file mode 100644 index cb3efe41..00000000 --- a/src/api/types/SegmentList.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Segment[]; - /** A pagination object, which may be empty, indicating no further pages to fetch. */ - pages?: Record; -} diff --git a/src/api/types/SingleFilterSearchRequest.ts b/src/api/types/SingleFilterSearchRequest.ts deleted file mode 100644 index b51eb1a2..00000000 --- a/src/api/types/SingleFilterSearchRequest.ts +++ /dev/null @@ -1,34 +0,0 @@ -// 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 const Operator = { - Equals: "=", - NotEquals: "!=", - In: "IN", - NotIn: "NIN", - LessThan: "<", - GreaterThan: ">", - Contains: "~", - DoesNotContain: "!~", - StartsWith: "^", - EndsWith: "$", - } as const; - export type Operator = (typeof Operator)[keyof typeof Operator]; - /** - * The value that you want to search on. - */ - export type Value = string | number | (string | number)[]; -} diff --git a/src/api/types/SlaApplied.ts b/src/api/types/SlaApplied.ts deleted file mode 100644 index 3ea77f62..00000000 --- a/src/api/types/SlaApplied.ts +++ /dev/null @@ -1,35 +0,0 @@ -// 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 const SlaStatus = { - Hit: "hit", - Missed: "missed", - Cancelled: "cancelled", - Active: "active", - } as const; - export type SlaStatus = (typeof SlaStatus)[keyof typeof SlaStatus]; -} diff --git a/src/api/types/SnoozeConversationRequest.ts b/src/api/types/SnoozeConversationRequest.ts deleted file mode 100644 index 7e3e7061..00000000 --- a/src/api/types/SnoozeConversationRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/SocialProfile.ts b/src/api/types/SocialProfile.ts deleted file mode 100644 index 78030405..00000000 --- a/src/api/types/SocialProfile.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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?: "social_profile"; - /** The name of the Social media profile */ - name?: string; - /** The name of the Social media profile */ - url?: string; -} diff --git a/src/api/types/StartingAfterPaging.ts b/src/api/types/StartingAfterPaging.ts deleted file mode 100644 index 6fc82b73..00000000 --- a/src/api/types/StartingAfterPaging.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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/types/SubscriptionTypeList.ts b/src/api/types/SubscriptionTypeList.ts deleted file mode 100644 index 134688b1..00000000 --- a/src/api/types/SubscriptionTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.SubscriptionType[]; -} diff --git a/src/api/types/TagCompanyRequest.ts b/src/api/types/TagCompanyRequest.ts deleted file mode 100644 index 4f4affb5..00000000 --- a/src/api/types/TagCompanyRequest.ts +++ /dev/null @@ -1,24 +0,0 @@ -// 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/types/TagList.ts b/src/api/types/TagList.ts deleted file mode 100644 index 54b9506c..00000000 --- a/src/api/types/TagList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Tag[]; -} diff --git a/src/api/types/TagMultipleUsersRequest.ts b/src/api/types/TagMultipleUsersRequest.ts deleted file mode 100644 index fc697987..00000000 --- a/src/api/types/TagMultipleUsersRequest.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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/types/Tags.ts b/src/api/types/Tags.ts deleted file mode 100644 index 0d3680ce..00000000 --- a/src/api/types/Tags.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Tag[]; -} diff --git a/src/api/types/TeamList.ts b/src/api/types/TeamList.ts deleted file mode 100644 index def5cbe1..00000000 --- a/src/api/types/TeamList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Team[]; -} diff --git a/src/api/types/TeamPriorityLevel.ts b/src/api/types/TeamPriorityLevel.ts deleted file mode 100644 index 07d6bae5..00000000 --- a/src/api/types/TeamPriorityLevel.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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/types/TicketCustomAttributes.ts b/src/api/types/TicketCustomAttributes.ts deleted file mode 100644 index 2596f28b..00000000 --- a/src/api/types/TicketCustomAttributes.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * 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; diff --git a/src/api/types/TicketList.ts b/src/api/types/TicketList.ts deleted file mode 100644 index e512f129..00000000 --- a/src/api/types/TicketList.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.Ticket | undefined)[]; - /** A count of the total number of objects. */ - total_count?: number; - pages?: Intercom.CursorPages; -} diff --git a/src/api/types/TicketPartAuthor.ts b/src/api/types/TicketPartAuthor.ts deleted file mode 100644 index e0ea7ff3..00000000 --- a/src/api/types/TicketPartAuthor.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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 const Type = { - Admin: "admin", - Bot: "bot", - Team: "team", - User: "user", - } as const; - export type Type = (typeof Type)[keyof typeof Type]; -} diff --git a/src/api/types/TicketParts.ts b/src/api/types/TicketParts.ts deleted file mode 100644 index 9ff75bbe..00000000 --- a/src/api/types/TicketParts.ts +++ /dev/null @@ -1,15 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.TicketPart[]; - /** */ - total_count?: number; -} diff --git a/src/api/types/TicketReply.ts b/src/api/types/TicketReply.ts deleted file mode 100644 index f86b2ef4..00000000 --- a/src/api/types/TicketReply.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.TicketPartAuthor; - /** A list of attachments for the part. */ - attachments?: Intercom.PartAttachment[]; - /** Whether or not the ticket part has been redacted. */ - redacted?: boolean; -} - -export namespace TicketReply { - /** Type of the part */ - export const PartType = { - Note: "note", - Comment: "comment", - QuickReply: "quick_reply", - } as const; - export type PartType = (typeof PartType)[keyof typeof PartType]; -} diff --git a/src/api/types/TicketRequestCustomAttributes.ts b/src/api/types/TicketRequestCustomAttributes.ts deleted file mode 100644 index f8cce5a3..00000000 --- a/src/api/types/TicketRequestCustomAttributes.ts +++ /dev/null @@ -1,6 +0,0 @@ -// 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; diff --git a/src/api/types/TicketStateList.ts b/src/api/types/TicketStateList.ts deleted file mode 100644 index ac2fbc51..00000000 --- a/src/api/types/TicketStateList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.TicketStateDetailed | undefined)[]; -} diff --git a/src/api/types/TicketTypeAttribute.ts b/src/api/types/TicketTypeAttribute.ts deleted file mode 100644 index 855266f6..00000000 --- a/src/api/types/TicketTypeAttribute.ts +++ /dev/null @@ -1,55 +0,0 @@ -// 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?: TicketTypeAttribute.DataType; - /** 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; -} - -export namespace TicketTypeAttribute { - /** The type of the data attribute (allowed values: "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; - export type DataType = (typeof DataType)[keyof typeof DataType]; -} diff --git a/src/api/types/TicketTypeAttributeList.ts b/src/api/types/TicketTypeAttributeList.ts deleted file mode 100644 index 6a9b00dc..00000000 --- a/src/api/types/TicketTypeAttributeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.TicketTypeAttribute | undefined)[]; -} diff --git a/src/api/types/TicketTypeList.ts b/src/api/types/TicketTypeList.ts deleted file mode 100644 index d76acea8..00000000 --- a/src/api/types/TicketTypeList.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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.TicketType | undefined)[]; -} diff --git a/src/api/types/Translation.ts b/src/api/types/Translation.ts deleted file mode 100644 index 3d656a16..00000000 --- a/src/api/types/Translation.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/UntagCompanyRequest.ts b/src/api/types/UntagCompanyRequest.ts deleted file mode 100644 index 09886bd1..00000000 --- a/src/api/types/UntagCompanyRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -// 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/types/UpdateArticleRequestBody.ts b/src/api/types/UpdateArticleRequestBody.ts deleted file mode 100644 index 3a5100b8..00000000 --- a/src/api/types/UpdateArticleRequestBody.ts +++ /dev/null @@ -1,13 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface UpdateArticleRequestBody { - parent_type?: UpdateArticleRequestBody.ParentType; -} - -export namespace UpdateArticleRequestBody { - export const ParentType = { - Collection: "collection", - Section: "section", - } as const; - export type ParentType = (typeof ParentType)[keyof typeof ParentType]; -} diff --git a/src/api/types/UpdateCompanyRequestBody.ts b/src/api/types/UpdateCompanyRequestBody.ts deleted file mode 100644 index 8949ca97..00000000 --- a/src/api/types/UpdateCompanyRequestBody.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * You can update a Company - */ -export interface UpdateCompanyRequestBody { - /** The name of the Company */ - name?: string; - /** The name of the plan you have associated with the company. */ - plan?: string; - /** The number of employees in this company. */ - size?: number; - /** The URL for this company's website. Please note that the value specified here is not validated. Accepts any string. */ - website?: string; - /** The industry that this company operates in. */ - industry?: string; - /** A hash of key/value pairs containing any other data about the company you want Intercom to store. */ - custom_attributes?: Record; - /** How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. */ - monthly_spend?: number; -} diff --git a/src/api/types/UpdateDataAttributeRequestBody.ts b/src/api/types/UpdateDataAttributeRequestBody.ts deleted file mode 100644 index 6524ae99..00000000 --- a/src/api/types/UpdateDataAttributeRequestBody.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * - */ -export type UpdateDataAttributeRequestBody = - | { - options: { - value?: string | undefined; - }[]; - } - | unknown; diff --git a/src/api/types/UpdateVisitorRequest.ts b/src/api/types/UpdateVisitorRequest.ts deleted file mode 100644 index 349fd6b2..00000000 --- a/src/api/types/UpdateVisitorRequest.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** - * Update an existing visitor. - */ -export type UpdateVisitorRequest = - | { - id: string; - name?: string | undefined; - custom_attributes?: Record | undefined; - } - | { - user_id: string; - name?: string | undefined; - custom_attributes?: Record | undefined; - }; diff --git a/src/api/types/UpdateVisitorRequestOne.ts b/src/api/types/UpdateVisitorRequestOne.ts deleted file mode 100644 index cfdac3c4..00000000 --- a/src/api/types/UpdateVisitorRequestOne.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export type UpdateVisitorRequestOne = unknown; diff --git a/src/api/types/Visitor.ts b/src/api/types/Visitor.ts deleted file mode 100644 index 5aa58457..00000000 --- a/src/api/types/Visitor.ts +++ /dev/null @@ -1,136 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Intercom from "../index.js"; - -/** - * 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: "visitor"; - /** 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.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/types/VisitorDeletedObject.ts b/src/api/types/VisitorDeletedObject.ts deleted file mode 100644 index 6a3cc196..00000000 --- a/src/api/types/VisitorDeletedObject.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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/types/WhatsappMessageStatusList.ts b/src/api/types/WhatsappMessageStatusList.ts deleted file mode 100644 index b1d0e8d8..00000000 --- a/src/api/types/WhatsappMessageStatusList.ts +++ /dev/null @@ -1,67 +0,0 @@ -// 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 const Status = { - Sent: "sent", - Delivered: "delivered", - Read: "read", - Failed: "failed", - } as const; - export type Status = (typeof Status)[keyof typeof Status]; - } - } -} diff --git a/src/api/types/index.ts b/src/api/types/index.ts deleted file mode 100644 index d0b6e87d..00000000 --- a/src/api/types/index.ts +++ /dev/null @@ -1,163 +0,0 @@ -export * from "./ActivityLog.js"; -export * from "./ActivityLogList.js"; -export * from "./ActivityLogMetadata.js"; -export * from "./AddressableList.js"; -export * from "./AdminList.js"; -export * from "./AdminPriorityLevel.js"; -export * from "./AdminReplyConversationRequest.js"; -export * from "./AdminReplyTicketRequest.js"; -export * from "./AdminWithApp.js"; -export * from "./App.js"; -export * from "./ArticleContent.js"; -export * from "./ArticleList.js"; -export * from "./ArticleStatistics.js"; -export * from "./ArticleTranslatedContent.js"; -export * from "./AssignConversationRequest.js"; -export * from "./AwayStatusReason.js"; -export * from "./CallList.js"; -export * from "./CloseConversationRequest.js"; -export * from "./CollectionList.js"; -export * from "./CompanyAttachedContacts.js"; -export * from "./CompanyAttachedSegments.js"; -export * from "./CompanyData.js"; -export * from "./CompanyList.js"; -export * from "./CompanyScroll.js"; -export * from "./ContactArchived.js"; -export * from "./ContactAttachedCompanies.js"; -export * from "./ContactBlocked.js"; -export * from "./ContactCompanies.js"; -export * from "./ContactDeleted.js"; -export * from "./ContactList.js"; -export * from "./ContactLocation.js"; -export * from "./ContactNotes.js"; -export * from "./ContactReference.js"; -export * from "./ContactReplyBaseRequest.js"; -export * from "./ContactReplyConversationRequest.js"; -export * from "./ContactReplyEmailRequest.js"; -export * from "./ContactReplyIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketEmailRequest.js"; -export * from "./ContactReplyTicketIntercomUserIdRequest.js"; -export * from "./ContactReplyTicketRequest.js"; -export * from "./ContactReplyTicketUserIdRequest.js"; -export * from "./ContactReplyUserIdRequest.js"; -export * from "./ContactSegments.js"; -export * from "./ContactSocialProfiles.js"; -export * from "./ContactSubscriptionTypes.js"; -export * from "./ContactTags.js"; -export * from "./ContactUnarchived.js"; -export * from "./ContentSourcesList.js"; -export * from "./ConversationAttachmentFiles.js"; -export * from "./ConversationAttributeUpdatedByAdmin.js"; -export * from "./ConversationAttributeUpdatedByWorkflow.js"; -export * from "./ConversationContacts.js"; -export * from "./ConversationDeleted.js"; -export * from "./ConversationFirstContactReply.js"; -export * from "./ConversationList.js"; -export * from "./ConversationPart.js"; -export * from "./ConversationPartAuthor.js"; -export * from "./ConversationPartMetadata.js"; -export * from "./ConversationParts.js"; -export * from "./ConversationRating.js"; -export * from "./ConversationResponseTime.js"; -export * from "./ConversationSource.js"; -export * from "./ConversationStatistics.js"; -export * from "./ConversationTeammates.js"; -export * from "./CreateArticleRequest.js"; -export * from "./CreateContactRequest.js"; -export * from "./CreateContactRequestTwo.js"; -export * from "./CreateDataAttributeRequest.js"; -export * from "./CreateDataEventRequest.js"; -export * from "./CreateDataEventRequestTwo.js"; -export * from "./CreateInternalArticleRequest.js"; -export * from "./CreateMessageRequest.js"; -export * from "./CreateOrUpdateCompanyRequest.js"; -export * from "./CreateOrUpdateTagRequest.js"; -export * from "./CreatePhoneSwitchRequest.js"; -export * from "./CreateTicketReplyWithCommentRequest.js"; -export * from "./CreateTicketRequestBody.js"; -export * from "./CreateTicketTypeRequest.js"; -export * from "./CursorPages.js"; -export * from "./CustomActionFinished.js"; -export * from "./CustomActionStarted.js"; -export * from "./CustomAttributes.js"; -export * from "./CustomChannelAttribute.js"; -export * from "./CustomChannelBaseEvent.js"; -export * from "./CustomChannelContact.js"; -export * from "./CustomChannelNotificationResponse.js"; -export * from "./CustomerRequest.js"; -export * from "./CustomObjectInstanceDeleted.js"; -export * from "./CustomObjectInstanceList.js"; -export * from "./DataAttributeList.js"; -export * from "./DataEventList.js"; -export * from "./DataEventSummary.js"; -export * from "./DataEventSummaryItem.js"; -export * from "./DataExportCsv.js"; -export * from "./Datetime.js"; -export * from "./DeletedArticleObject.js"; -export * from "./DeletedCollectionObject.js"; -export * from "./DeletedCompanyObject.js"; -export * from "./DeletedInternalArticleObject.js"; -export * from "./DeletedObject.js"; -export * from "./EmailAddressHeader.js"; -export * from "./EmailMessageMetadata.js"; -export * from "./Error_.js"; -export * from "./EventDetails.js"; -export * from "./FileAttribute.js"; -export * from "./GroupContent.js"; -export * from "./GroupTranslatedContent.js"; -export * from "./InternalArticleList.js"; -export * from "./IpAllowlist.js"; -export * from "./LinkedObject.js"; -export * from "./LinkedObjectList.js"; -export * from "./Metadata.js"; -export * from "./MultipleFilterSearchRequest.js"; -export * from "./NewsItemRequest.js"; -export * from "./NoteList.js"; -export * from "./NotFoundErrorBody.js"; -export * from "./OffsetPages.js"; -export * from "./OpenConversationRequest.js"; -export * from "./OperatorWorkflowEvent.js"; -export * from "./PagesLink.js"; -export * from "./PaginatedResponse.js"; -export * from "./PaginatedResponseDataItem.js"; -export * from "./PartAttachment.js"; -export * from "./PhoneSwitch.js"; -export * from "./QuickReplyOption.js"; -export * from "./Recipient.js"; -export * from "./RedactConversationRequest.js"; -export * from "./Reference.js"; -export * from "./ReplyConversationRequest.js"; -export * from "./SearchRequest.js"; -export * from "./SegmentList.js"; -export * from "./SingleFilterSearchRequest.js"; -export * from "./SlaApplied.js"; -export * from "./SnoozeConversationRequest.js"; -export * from "./SocialProfile.js"; -export * from "./StartingAfterPaging.js"; -export * from "./SubscriptionTypeList.js"; -export * from "./TagCompanyRequest.js"; -export * from "./TagList.js"; -export * from "./TagMultipleUsersRequest.js"; -export * from "./Tags.js"; -export * from "./TeamList.js"; -export * from "./TeamPriorityLevel.js"; -export * from "./TicketCustomAttributes.js"; -export * from "./TicketList.js"; -export * from "./TicketPartAuthor.js"; -export * from "./TicketParts.js"; -export * from "./TicketReply.js"; -export * from "./TicketRequestCustomAttributes.js"; -export * from "./TicketStateList.js"; -export * from "./TicketTypeAttribute.js"; -export * from "./TicketTypeAttributeList.js"; -export * from "./TicketTypeList.js"; -export * from "./Translation.js"; -export * from "./UntagCompanyRequest.js"; -export * from "./UpdateArticleRequestBody.js"; -export * from "./UpdateCompanyRequestBody.js"; -export * from "./UpdateDataAttributeRequestBody.js"; -export * from "./UpdateVisitorRequest.js"; -export * from "./UpdateVisitorRequestOne.js"; -export * from "./Visitor.js"; -export * from "./VisitorDeletedObject.js"; -export * from "./WhatsappMessageStatusList.js"; diff --git a/src/api/version.ts b/src/api/version.ts deleted file mode 100644 index 54e211cb..00000000 --- a/src/api/version.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -/** The version of the API, sent as the Intercom-Version header. */ -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" - | "2.12" - | "2.13" - | "2.14" - | "Unstable"; diff --git a/src/auth/BearerAuthProvider.ts b/src/auth/BearerAuthProvider.ts deleted file mode 100644 index fc69deba..00000000 --- a/src/auth/BearerAuthProvider.ts +++ /dev/null @@ -1,36 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as core from "../core/index.js"; -import * as errors from "../errors/index.js"; - -export namespace BearerAuthProvider { - export interface Options { - token?: core.Supplier; - } -} - -export class BearerAuthProvider implements core.AuthProvider { - private readonly token: core.Supplier | undefined; - - constructor(options: BearerAuthProvider.Options) { - this.token = options.token; - } - - public static canCreate(options: BearerAuthProvider.Options): boolean { - return options.token != null || process.env?.INTERCOM_API_KEY != null; - } - - public async getAuthRequest(_arg?: { endpointMetadata?: core.EndpointMetadata }): Promise { - const token = (await core.Supplier.get(this.token)) ?? process.env?.INTERCOM_API_KEY; - if (token == null) { - throw new errors.IntercomError({ - message: - "Please specify a token by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", - }); - } - - return { - headers: { Authorization: `Bearer ${token}` }, - }; - } -} diff --git a/src/auth/index.ts b/src/auth/index.ts deleted file mode 100644 index 0ecb12b7..00000000 --- a/src/auth/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { BearerAuthProvider } from "./BearerAuthProvider.js"; diff --git a/src/core.ts b/src/core.ts new file mode 100644 index 00000000..417e529a --- /dev/null +++ b/src/core.ts @@ -0,0 +1,1165 @@ +import { VERSION } from './version'; +import { + IntercomError, + APIError, + APIConnectionError, + APIConnectionTimeoutError, + APIUserAbortError, +} from './error'; +import { + kind as shimsKind, + type Readable, + getDefaultAgent, + type Agent, + fetch, + type RequestInfo, + type RequestInit, + type Response, + type HeadersInit, +} from './_shims/index'; +export { type Response }; +import { BlobLike, isBlobLike, isMultipartBody } from './uploads'; +export { + maybeMultipartFormRequestOptions, + multipartFormRequestOptions, + createForm, + type Uploadable, +} from './uploads'; + +export type Fetch = (url: RequestInfo, init?: RequestInit) => Promise; + +type PromiseOrValue = T | Promise; + +type APIResponseProps = { + response: Response; + options: FinalRequestOptions; + controller: AbortController; +}; + +async function defaultParseResponse(props: APIResponseProps): Promise { + const { response } = props; + // fetch refuses to read the body when the status code is 204. + if (response.status === 204) { + return null as T; + } + + if (props.options.__binaryResponse) { + return response as unknown as T; + } + + const contentType = response.headers.get('content-type'); + const isJSON = + contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json'); + if (isJSON) { + const json = await response.json(); + + debug('response', response.status, response.url, response.headers, json); + + return json as T; + } + + const text = await response.text(); + debug('response', response.status, response.url, response.headers, text); + + // TODO handle blob, arraybuffer, other content types, etc. + return text as unknown as T; +} + +/** + * A subclass of `Promise` providing additional helper methods + * for interacting with the SDK. + */ +export class APIPromise extends Promise { + private parsedPromise: Promise | undefined; + + constructor( + private responsePromise: Promise, + private parseResponse: (props: APIResponseProps) => PromiseOrValue = defaultParseResponse, + ) { + super((resolve) => { + // this is maybe a bit weird but this has to be a no-op to not implicitly + // parse the response body; instead .then, .catch, .finally are overridden + // to parse the response + resolve(null as any); + }); + } + + _thenUnwrap(transform: (data: T) => U): APIPromise { + return new APIPromise(this.responsePromise, async (props) => transform(await this.parseResponse(props))); + } + + /** + * Gets the raw `Response` instance instead of parsing the response + * data. + * + * If you want to parse the response body but still get the `Response` + * instance, you can use {@link withResponse()}. + * + * 👋 Getting the wrong TypeScript type for `Response`? + * Try setting `"moduleResolution": "NodeNext"` if you can, + * or add one of these imports before your first `import … from 'intercom-client'`: + * - `import 'intercom-client/shims/node'` (if you're running on Node) + * - `import 'intercom-client/shims/web'` (otherwise) + */ + asResponse(): Promise { + return this.responsePromise.then((p) => p.response); + } + /** + * Gets the parsed response data and the raw `Response` instance. + * + * If you just want to get the raw `Response` instance without parsing it, + * you can use {@link asResponse()}. + * + * + * 👋 Getting the wrong TypeScript type for `Response`? + * Try setting `"moduleResolution": "NodeNext"` if you can, + * or add one of these imports before your first `import … from 'intercom-client'`: + * - `import 'intercom-client/shims/node'` (if you're running on Node) + * - `import 'intercom-client/shims/web'` (otherwise) + */ + async withResponse(): Promise<{ data: T; response: Response }> { + const [data, response] = await Promise.all([this.parse(), this.asResponse()]); + return { data, response }; + } + + private parse(): Promise { + if (!this.parsedPromise) { + this.parsedPromise = this.responsePromise.then(this.parseResponse); + } + return this.parsedPromise; + } + + override then( + onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null, + ): Promise { + return this.parse().then(onfulfilled, onrejected); + } + + override catch( + onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null, + ): Promise { + return this.parse().catch(onrejected); + } + + override finally(onfinally?: (() => void) | undefined | null): Promise { + return this.parse().finally(onfinally); + } +} + +export abstract class APIClient { + baseURL: string; + maxRetries: number; + timeout: number; + httpAgent: Agent | undefined; + + private fetch: Fetch; + protected idempotencyHeader?: string; + + constructor({ + baseURL, + maxRetries = 2, + timeout = 60000, // 1 minute + httpAgent, + fetch: overridenFetch, + }: { + baseURL: string; + maxRetries?: number | undefined; + timeout: number | undefined; + httpAgent: Agent | undefined; + fetch: Fetch | undefined; + }) { + this.baseURL = baseURL; + this.maxRetries = validatePositiveInteger('maxRetries', maxRetries); + this.timeout = validatePositiveInteger('timeout', timeout); + this.httpAgent = httpAgent; + + this.fetch = overridenFetch ?? fetch; + } + + protected authHeaders(opts: FinalRequestOptions): Headers { + return {}; + } + + /** + * Override this to add your own default headers, for example: + * + * { + * ...super.defaultHeaders(), + * Authorization: 'Bearer 123', + * } + */ + protected defaultHeaders(opts: FinalRequestOptions): Headers { + return { + Accept: 'application/json', + 'Content-Type': 'application/json', + 'User-Agent': this.getUserAgent(), + ...getPlatformHeaders(), + ...this.authHeaders(opts), + }; + } + + protected abstract defaultQuery(): DefaultQuery | undefined; + + /** + * Override this to add your own headers validation: + */ + protected validateHeaders(headers: Headers, customHeaders: Headers) {} + + protected defaultIdempotencyKey(): string { + return `stainless-node-retry-${uuid4()}`; + } + + get(path: string, opts?: PromiseOrValue>): APIPromise { + return this.methodRequest('get', path, opts); + } + + post(path: string, opts?: PromiseOrValue>): APIPromise { + return this.methodRequest('post', path, opts); + } + + patch(path: string, opts?: PromiseOrValue>): APIPromise { + return this.methodRequest('patch', path, opts); + } + + put(path: string, opts?: PromiseOrValue>): APIPromise { + return this.methodRequest('put', path, opts); + } + + delete(path: string, opts?: PromiseOrValue>): APIPromise { + return this.methodRequest('delete', path, opts); + } + + private methodRequest( + method: HTTPMethod, + path: string, + opts?: PromiseOrValue>, + ): APIPromise { + return this.request( + Promise.resolve(opts).then(async (opts) => { + const body = + opts && isBlobLike(opts?.body) ? new DataView(await opts.body.arrayBuffer()) + : opts?.body instanceof DataView ? opts.body + : opts?.body instanceof ArrayBuffer ? new DataView(opts.body) + : opts && ArrayBuffer.isView(opts?.body) ? new DataView(opts.body.buffer) + : opts?.body; + return { method, path, ...opts, body }; + }), + ); + } + + getAPIList = AbstractPage>( + path: string, + Page: new (...args: any[]) => PageClass, + opts?: RequestOptions, + ): PagePromise { + return this.requestAPIList(Page, { method: 'get', path, ...opts }); + } + + private calculateContentLength(body: unknown): string | null { + if (typeof body === 'string') { + if (typeof Buffer !== 'undefined') { + return Buffer.byteLength(body, 'utf8').toString(); + } + + if (typeof TextEncoder !== 'undefined') { + const encoder = new TextEncoder(); + const encoded = encoder.encode(body); + return encoded.length.toString(); + } + } else if (ArrayBuffer.isView(body)) { + return body.byteLength.toString(); + } + + return null; + } + + buildRequest(options: FinalRequestOptions): { req: RequestInit; url: string; timeout: number } { + const { method, path, query, headers: headers = {} } = options; + + const body = + ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ? + options.body + : isMultipartBody(options.body) ? options.body.body + : options.body ? JSON.stringify(options.body, null, 2) + : null; + const contentLength = this.calculateContentLength(body); + + const url = this.buildURL(path!, query); + if ('timeout' in options) validatePositiveInteger('timeout', options.timeout); + const timeout = options.timeout ?? this.timeout; + const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url); + const minAgentTimeout = timeout + 1000; + if ( + typeof (httpAgent as any)?.options?.timeout === 'number' && + minAgentTimeout > ((httpAgent as any).options.timeout ?? 0) + ) { + // Allow any given request to bump our agent active socket timeout. + // This may seem strange, but leaking active sockets should be rare and not particularly problematic, + // and without mutating agent we would need to create more of them. + // This tradeoff optimizes for performance. + (httpAgent as any).options.timeout = minAgentTimeout; + } + + if (this.idempotencyHeader && method !== 'get') { + if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey(); + headers[this.idempotencyHeader] = options.idempotencyKey; + } + + const reqHeaders = this.buildHeaders({ options, headers, contentLength }); + + const req: RequestInit = { + method, + ...(body && { body: body as any }), + headers: reqHeaders, + ...(httpAgent && { agent: httpAgent }), + // @ts-ignore node-fetch uses a custom AbortSignal type that is + // not compatible with standard web types + signal: options.signal ?? null, + }; + + return { req, url, timeout }; + } + + private buildHeaders({ + options, + headers, + contentLength, + }: { + options: FinalRequestOptions; + headers: Record; + contentLength: string | null | undefined; + }): Record { + const reqHeaders: Record = {}; + if (contentLength) { + reqHeaders['content-length'] = contentLength; + } + + const defaultHeaders = this.defaultHeaders(options); + applyHeadersMut(reqHeaders, defaultHeaders); + applyHeadersMut(reqHeaders, headers); + + // let builtin fetch set the Content-Type for multipart bodies + if (isMultipartBody(options.body) && shimsKind !== 'node') { + delete reqHeaders['content-type']; + } + + this.validateHeaders(reqHeaders, headers); + + return reqHeaders; + } + + /** + * Used as a callback for mutating the given `FinalRequestOptions` object. + */ + protected async prepareOptions(options: FinalRequestOptions): Promise {} + + /** + * Used as a callback for mutating the given `RequestInit` object. + * + * This is useful for cases where you want to add certain headers based off of + * the request properties, e.g. `method` or `url`. + */ + protected async prepareRequest( + request: RequestInit, + { url, options }: { url: string; options: FinalRequestOptions }, + ): Promise {} + + protected parseHeaders(headers: HeadersInit | null | undefined): Record { + return ( + !headers ? {} + : Symbol.iterator in headers ? + Object.fromEntries(Array.from(headers as Iterable).map((header) => [...header])) + : { ...headers } + ); + } + + protected makeStatusError( + status: number | undefined, + error: Object | undefined, + message: string | undefined, + headers: Headers | undefined, + ) { + return APIError.generate(status, error, message, headers); + } + + request( + options: PromiseOrValue>, + remainingRetries: number | null = null, + ): APIPromise { + return new APIPromise(this.makeRequest(options, remainingRetries)); + } + + private async makeRequest( + optionsInput: PromiseOrValue>, + retriesRemaining: number | null, + ): Promise { + const options = await optionsInput; + if (retriesRemaining == null) { + retriesRemaining = options.maxRetries ?? this.maxRetries; + } + + await this.prepareOptions(options); + + const { req, url, timeout } = this.buildRequest(options); + + await this.prepareRequest(req, { url, options }); + + debug('request', url, options, req.headers); + + if (options.signal?.aborted) { + throw new APIUserAbortError(); + } + + const controller = new AbortController(); + const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError); + + if (response instanceof Error) { + if (options.signal?.aborted) { + throw new APIUserAbortError(); + } + if (retriesRemaining) { + return this.retryRequest(options, retriesRemaining); + } + if (response.name === 'AbortError') { + throw new APIConnectionTimeoutError(); + } + throw new APIConnectionError({ cause: response }); + } + + const responseHeaders = createResponseHeaders(response.headers); + + if (!response.ok) { + if (retriesRemaining && this.shouldRetry(response)) { + const retryMessage = `retrying, ${retriesRemaining} attempts remaining`; + debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders); + return this.retryRequest(options, retriesRemaining, responseHeaders); + } + + const errText = await response.text().catch((e) => castToError(e).message); + const errJSON = safeJSON(errText); + const errMessage = errJSON ? undefined : errText; + const retryMessage = retriesRemaining ? `(error; no more retries left)` : `(error; not retryable)`; + + debug(`response (error; ${retryMessage})`, response.status, url, responseHeaders, errMessage); + + const err = this.makeStatusError(response.status, errJSON, errMessage, responseHeaders); + throw err; + } + + return { response, options, controller }; + } + + requestAPIList = AbstractPage>( + Page: new (...args: ConstructorParameters) => PageClass, + options: FinalRequestOptions, + ): PagePromise { + const request = this.makeRequest(options, null); + return new PagePromise(this, request, Page); + } + + buildURL(path: string, query: Req | null | undefined): string { + const url = + isAbsoluteURL(path) ? + new URL(path) + : new URL(this.baseURL + (this.baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); + + const defaultQuery = this.defaultQuery(); + if (!isEmptyObj(defaultQuery)) { + query = { ...defaultQuery, ...query } as Req; + } + + if (typeof query === 'object' && query && !Array.isArray(query)) { + url.search = this.stringifyQuery(query as Record); + } + + return url.toString(); + } + + protected stringifyQuery(query: Record): string { + return Object.entries(query) + .filter(([_, value]) => typeof value !== 'undefined') + .map(([key, value]) => { + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { + return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`; + } + if (value === null) { + return `${encodeURIComponent(key)}=`; + } + throw new IntercomError( + `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`, + ); + }) + .join('&'); + } + + async fetchWithTimeout( + url: RequestInfo, + init: RequestInit | undefined, + ms: number, + controller: AbortController, + ): Promise { + const { signal, ...options } = init || {}; + if (signal) signal.addEventListener('abort', () => controller.abort()); + + const timeout = setTimeout(() => controller.abort(), ms); + + return ( + this.getRequestClient() + // use undefined this binding; fetch errors if bound to something else in browser/cloudflare + .fetch.call(undefined, url, { signal: controller.signal as any, ...options }) + .finally(() => { + clearTimeout(timeout); + }) + ); + } + + protected getRequestClient(): RequestClient { + return { fetch: this.fetch }; + } + + private shouldRetry(response: Response): boolean { + // Note this is not a standard header. + const shouldRetryHeader = response.headers.get('x-should-retry'); + + // If the server explicitly says whether or not to retry, obey. + if (shouldRetryHeader === 'true') return true; + if (shouldRetryHeader === 'false') return false; + + // Retry on request timeouts. + if (response.status === 408) return true; + + // Retry on lock timeouts. + if (response.status === 409) return true; + + // Retry on rate limits. + if (response.status === 429) return true; + + // Retry internal errors. + if (response.status >= 500) return true; + + return false; + } + + private async retryRequest( + options: FinalRequestOptions, + retriesRemaining: number, + responseHeaders?: Headers | undefined, + ): Promise { + let timeoutMillis: number | undefined; + + // Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it. + const retryAfterMillisHeader = responseHeaders?.['retry-after-ms']; + if (retryAfterMillisHeader) { + const timeoutMs = parseFloat(retryAfterMillisHeader); + if (!Number.isNaN(timeoutMs)) { + timeoutMillis = timeoutMs; + } + } + + // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + const retryAfterHeader = responseHeaders?.['retry-after']; + if (retryAfterHeader && !timeoutMillis) { + const timeoutSeconds = parseFloat(retryAfterHeader); + if (!Number.isNaN(timeoutSeconds)) { + timeoutMillis = timeoutSeconds * 1000; + } else { + timeoutMillis = Date.parse(retryAfterHeader) - Date.now(); + } + } + + // If the API asks us to wait a certain amount of time (and it's a reasonable amount), + // just do what it says, but otherwise calculate a default + if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) { + const maxRetries = options.maxRetries ?? this.maxRetries; + timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries); + } + await sleep(timeoutMillis); + + return this.makeRequest(options, retriesRemaining - 1); + } + + private calculateDefaultRetryTimeoutMillis(retriesRemaining: number, maxRetries: number): number { + const initialRetryDelay = 0.5; + const maxRetryDelay = 8.0; + + const numRetries = maxRetries - retriesRemaining; + + // Apply exponential backoff, but not more than the max. + const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay); + + // Apply some jitter, take up to at most 25 percent of the retry time. + const jitter = 1 - Math.random() * 0.25; + + return sleepSeconds * jitter * 1000; + } + + private getUserAgent(): string { + return `${this.constructor.name}/JS ${VERSION}`; + } +} + +export type PageInfo = { url: URL } | { params: Record | null }; + +export abstract class AbstractPage implements AsyncIterable { + #client: APIClient; + protected options: FinalRequestOptions; + + protected response: Response; + protected body: unknown; + + constructor(client: APIClient, response: Response, body: unknown, options: FinalRequestOptions) { + this.#client = client; + this.options = options; + this.response = response; + this.body = body; + } + + /** + * @deprecated Use nextPageInfo instead + */ + abstract nextPageParams(): Partial> | null; + abstract nextPageInfo(): PageInfo | null; + + abstract getPaginatedItems(): Item[]; + + hasNextPage(): boolean { + const items = this.getPaginatedItems(); + if (!items.length) return false; + return this.nextPageInfo() != null; + } + + async getNextPage(): Promise { + const nextInfo = this.nextPageInfo(); + if (!nextInfo) { + throw new IntercomError( + 'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.', + ); + } + const nextOptions = { ...this.options }; + if ('params' in nextInfo && typeof nextOptions.query === 'object') { + nextOptions.query = { ...nextOptions.query, ...nextInfo.params }; + } else if ('url' in nextInfo) { + const params = [...Object.entries(nextOptions.query || {}), ...nextInfo.url.searchParams.entries()]; + for (const [key, value] of params) { + nextInfo.url.searchParams.set(key, value as any); + } + nextOptions.query = undefined; + nextOptions.path = nextInfo.url.toString(); + } + return await this.#client.requestAPIList(this.constructor as any, nextOptions); + } + + async *iterPages() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + let page: AbstractPage = this; + yield page; + while (page.hasNextPage()) { + page = await page.getNextPage(); + yield page; + } + } + + async *[Symbol.asyncIterator]() { + for await (const page of this.iterPages()) { + for (const item of page.getPaginatedItems()) { + yield item; + } + } + } +} + +/** + * This subclass of Promise will resolve to an instantiated Page once the request completes. + * + * It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg: + * + * for await (const item of client.items.list()) { + * console.log(item) + * } + */ +export class PagePromise< + PageClass extends AbstractPage, + Item = ReturnType[number], + > + extends APIPromise + implements AsyncIterable +{ + constructor( + client: APIClient, + request: Promise, + Page: new (...args: ConstructorParameters) => PageClass, + ) { + super( + request, + async (props) => new Page(client, props.response, await defaultParseResponse(props), props.options), + ); + } + + /** + * Allow auto-paginating iteration on an unawaited list call, eg: + * + * for await (const item of client.items.list()) { + * console.log(item) + * } + */ + async *[Symbol.asyncIterator]() { + const page = await this; + for await (const item of page) { + yield item; + } + } +} + +export const createResponseHeaders = ( + headers: Awaited>['headers'], +): Record => { + return new Proxy( + Object.fromEntries( + // @ts-ignore + headers.entries(), + ), + { + get(target, name) { + const key = name.toString(); + return target[key.toLowerCase()] || target[key]; + }, + }, + ); +}; + +type HTTPMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; + +export type RequestClient = { fetch: Fetch }; +export type Headers = Record; +export type DefaultQuery = Record; +export type KeysEnum = { [P in keyof Required]: true }; + +export type RequestOptions< + Req = unknown | Record | Readable | BlobLike | ArrayBufferView | ArrayBuffer, +> = { + method?: HTTPMethod; + path?: string; + query?: Req | undefined; + body?: Req | null | undefined; + headers?: Headers | undefined; + + maxRetries?: number; + stream?: boolean | undefined; + timeout?: number; + httpAgent?: Agent; + signal?: AbortSignal | undefined | null; + idempotencyKey?: string; + + __binaryRequest?: boolean | undefined; + __binaryResponse?: boolean | undefined; +}; + +// This is required so that we can determine if a given object matches the RequestOptions +// type at runtime. While this requires duplication, it is enforced by the TypeScript +// compiler such that any missing / extraneous keys will cause an error. +const requestOptionsKeys: KeysEnum = { + method: true, + path: true, + query: true, + body: true, + headers: true, + + maxRetries: true, + stream: true, + timeout: true, + httpAgent: true, + signal: true, + idempotencyKey: true, + + __binaryRequest: true, + __binaryResponse: true, +}; + +export const isRequestOptions = (obj: unknown): obj is RequestOptions => { + return ( + typeof obj === 'object' && + obj !== null && + !isEmptyObj(obj) && + Object.keys(obj).every((k) => hasOwn(requestOptionsKeys, k)) + ); +}; + +export type FinalRequestOptions | Readable | DataView> = + RequestOptions & { + method: HTTPMethod; + path: string; + }; + +declare const Deno: any; +declare const EdgeRuntime: any; +type Arch = 'x32' | 'x64' | 'arm' | 'arm64' | `other:${string}` | 'unknown'; +type PlatformName = + | 'MacOS' + | 'Linux' + | 'Windows' + | 'FreeBSD' + | 'OpenBSD' + | 'iOS' + | 'Android' + | `Other:${string}` + | 'Unknown'; +type Browser = 'ie' | 'edge' | 'chrome' | 'firefox' | 'safari'; +type PlatformProperties = { + 'X-Stainless-Lang': 'js'; + 'X-Stainless-Package-Version': string; + 'X-Stainless-OS': PlatformName; + 'X-Stainless-Arch': Arch; + 'X-Stainless-Runtime': 'node' | 'deno' | 'edge' | `browser:${Browser}` | 'unknown'; + 'X-Stainless-Runtime-Version': string; +}; +const getPlatformProperties = (): PlatformProperties => { + if (typeof Deno !== 'undefined' && Deno.build != null) { + return { + 'X-Stainless-Lang': 'js', + 'X-Stainless-Package-Version': VERSION, + 'X-Stainless-OS': normalizePlatform(Deno.build.os), + 'X-Stainless-Arch': normalizeArch(Deno.build.arch), + 'X-Stainless-Runtime': 'deno', + 'X-Stainless-Runtime-Version': + typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown', + }; + } + if (typeof EdgeRuntime !== 'undefined') { + return { + 'X-Stainless-Lang': 'js', + 'X-Stainless-Package-Version': VERSION, + 'X-Stainless-OS': 'Unknown', + 'X-Stainless-Arch': `other:${EdgeRuntime}`, + 'X-Stainless-Runtime': 'edge', + 'X-Stainless-Runtime-Version': process.version, + }; + } + // Check if Node.js + if (Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]') { + return { + 'X-Stainless-Lang': 'js', + 'X-Stainless-Package-Version': VERSION, + 'X-Stainless-OS': normalizePlatform(process.platform), + 'X-Stainless-Arch': normalizeArch(process.arch), + 'X-Stainless-Runtime': 'node', + 'X-Stainless-Runtime-Version': process.version, + }; + } + + const browserInfo = getBrowserInfo(); + if (browserInfo) { + return { + 'X-Stainless-Lang': 'js', + 'X-Stainless-Package-Version': VERSION, + 'X-Stainless-OS': 'Unknown', + 'X-Stainless-Arch': 'unknown', + 'X-Stainless-Runtime': `browser:${browserInfo.browser}`, + 'X-Stainless-Runtime-Version': browserInfo.version, + }; + } + + // TODO add support for Cloudflare workers, etc. + return { + 'X-Stainless-Lang': 'js', + 'X-Stainless-Package-Version': VERSION, + 'X-Stainless-OS': 'Unknown', + 'X-Stainless-Arch': 'unknown', + 'X-Stainless-Runtime': 'unknown', + 'X-Stainless-Runtime-Version': 'unknown', + }; +}; + +type BrowserInfo = { + browser: Browser; + version: string; +}; + +declare const navigator: { userAgent: string } | undefined; + +// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts +function getBrowserInfo(): BrowserInfo | null { + if (typeof navigator === 'undefined' || !navigator) { + return null; + } + + // NOTE: The order matters here! + const browserPatterns = [ + { key: 'edge' as const, pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, + { key: 'ie' as const, pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, + { key: 'ie' as const, pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ }, + { key: 'chrome' as const, pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, + { key: 'firefox' as const, pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ }, + { key: 'safari' as const, pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }, + ]; + + // Find the FIRST matching browser + for (const { key, pattern } of browserPatterns) { + const match = pattern.exec(navigator.userAgent); + if (match) { + const major = match[1] || 0; + const minor = match[2] || 0; + const patch = match[3] || 0; + + return { browser: key, version: `${major}.${minor}.${patch}` }; + } + } + + return null; +} + +const normalizeArch = (arch: string): Arch => { + // Node docs: + // - https://nodejs.org/api/process.html#processarch + // Deno docs: + // - https://doc.deno.land/deno/stable/~/Deno.build + if (arch === 'x32') return 'x32'; + if (arch === 'x86_64' || arch === 'x64') return 'x64'; + if (arch === 'arm') return 'arm'; + if (arch === 'aarch64' || arch === 'arm64') return 'arm64'; + if (arch) return `other:${arch}`; + return 'unknown'; +}; + +const normalizePlatform = (platform: string): PlatformName => { + // Node platforms: + // - https://nodejs.org/api/process.html#processplatform + // Deno platforms: + // - https://doc.deno.land/deno/stable/~/Deno.build + // - https://github.com/denoland/deno/issues/14799 + + platform = platform.toLowerCase(); + + // NOTE: this iOS check is untested and may not work + // Node does not work natively on IOS, there is a fork at + // https://github.com/nodejs-mobile/nodejs-mobile + // however it is unknown at the time of writing how to detect if it is running + if (platform.includes('ios')) return 'iOS'; + if (platform === 'android') return 'Android'; + if (platform === 'darwin') return 'MacOS'; + if (platform === 'win32') return 'Windows'; + if (platform === 'freebsd') return 'FreeBSD'; + if (platform === 'openbsd') return 'OpenBSD'; + if (platform === 'linux') return 'Linux'; + if (platform) return `Other:${platform}`; + return 'Unknown'; +}; + +let _platformHeaders: PlatformProperties; +const getPlatformHeaders = () => { + return (_platformHeaders ??= getPlatformProperties()); +}; + +export const safeJSON = (text: string) => { + try { + return JSON.parse(text); + } catch (err) { + return undefined; + } +}; + +// https://stackoverflow.com/a/19709846 +const startsWithSchemeRegexp = new RegExp('^(?:[a-z]+:)?//', 'i'); +const isAbsoluteURL = (url: string): boolean => { + return startsWithSchemeRegexp.test(url); +}; + +export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +const validatePositiveInteger = (name: string, n: unknown): number => { + if (typeof n !== 'number' || !Number.isInteger(n)) { + throw new IntercomError(`${name} must be an integer`); + } + if (n < 0) { + throw new IntercomError(`${name} must be a positive integer`); + } + return n; +}; + +export const castToError = (err: any): Error => { + if (err instanceof Error) return err; + return new Error(err); +}; + +export const ensurePresent = (value: T | null | undefined): T => { + if (value == null) throw new IntercomError(`Expected a value to be given but received ${value} instead.`); + return value; +}; + +/** + * Read an environment variable. + * + * Trims beginning and trailing whitespace. + * + * Will return undefined if the environment variable doesn't exist or cannot be accessed. + */ +export const readEnv = (env: string): string | undefined => { + if (typeof process !== 'undefined') { + return process.env?.[env]?.trim() ?? undefined; + } + if (typeof Deno !== 'undefined') { + return Deno.env?.get?.(env)?.trim(); + } + return undefined; +}; + +export const coerceInteger = (value: unknown): number => { + if (typeof value === 'number') return Math.round(value); + if (typeof value === 'string') return parseInt(value, 10); + + throw new IntercomError(`Could not coerce ${value} (type: ${typeof value}) into a number`); +}; + +export const coerceFloat = (value: unknown): number => { + if (typeof value === 'number') return value; + if (typeof value === 'string') return parseFloat(value); + + throw new IntercomError(`Could not coerce ${value} (type: ${typeof value}) into a number`); +}; + +export const coerceBoolean = (value: unknown): boolean => { + if (typeof value === 'boolean') return value; + if (typeof value === 'string') return value === 'true'; + return Boolean(value); +}; + +export const maybeCoerceInteger = (value: unknown): number | undefined => { + if (value === undefined) { + return undefined; + } + return coerceInteger(value); +}; + +export const maybeCoerceFloat = (value: unknown): number | undefined => { + if (value === undefined) { + return undefined; + } + return coerceFloat(value); +}; + +export const maybeCoerceBoolean = (value: unknown): boolean | undefined => { + if (value === undefined) { + return undefined; + } + return coerceBoolean(value); +}; + +// https://stackoverflow.com/a/34491287 +export function isEmptyObj(obj: Object | null | undefined): boolean { + if (!obj) return true; + for (const _k in obj) return false; + return true; +} + +// https://eslint.org/docs/latest/rules/no-prototype-builtins +export function hasOwn(obj: Object, key: string): boolean { + return Object.prototype.hasOwnProperty.call(obj, key); +} + +/** + * Copies headers from "newHeaders" onto "targetHeaders", + * using lower-case for all properties, + * ignoring any keys with undefined values, + * and deleting any keys with null values. + */ +function applyHeadersMut(targetHeaders: Headers, newHeaders: Headers): void { + for (const k in newHeaders) { + if (!hasOwn(newHeaders, k)) continue; + const lowerKey = k.toLowerCase(); + if (!lowerKey) continue; + + const val = newHeaders[k]; + + if (val === null) { + delete targetHeaders[lowerKey]; + } else if (val !== undefined) { + targetHeaders[lowerKey] = val; + } + } +} + +export function debug(action: string, ...args: any[]) { + if (typeof process !== 'undefined' && process?.env?.['DEBUG'] === 'true') { + console.log(`Intercom:DEBUG:${action}`, ...args); + } +} + +/** + * https://stackoverflow.com/a/2117523 + */ +const uuid4 = () => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +}; + +export const isRunningInBrowser = () => { + return ( + // @ts-ignore + typeof window !== 'undefined' && + // @ts-ignore + typeof window.document !== 'undefined' && + // @ts-ignore + typeof navigator !== 'undefined' + ); +}; + +export interface HeadersProtocol { + get: (header: string) => string | null | undefined; +} +export type HeadersLike = Record | HeadersProtocol; + +export const isHeadersProtocol = (headers: any): headers is HeadersProtocol => { + return typeof headers?.get === 'function'; +}; + +export const getRequiredHeader = (headers: HeadersLike, header: string): string => { + const lowerCasedHeader = header.toLowerCase(); + if (isHeadersProtocol(headers)) { + // to deal with the case where the header looks like Stainless-Event-Id + const intercapsHeader = + header[0]?.toUpperCase() + + header.substring(1).replace(/([^\w])(\w)/g, (_m, g1, g2) => g1 + g2.toUpperCase()); + for (const key of [header, lowerCasedHeader, header.toUpperCase(), intercapsHeader]) { + const value = headers.get(key); + if (value) { + return value; + } + } + } + + for (const [key, value] of Object.entries(headers)) { + if (key.toLowerCase() === lowerCasedHeader) { + if (Array.isArray(value)) { + if (value.length <= 1) return value[0]; + console.warn(`Received ${value.length} entries for the ${header} header, using the first entry.`); + return value[0]; + } + return value; + } + } + + throw new Error(`Could not find ${header} header`); +}; + +/** + * Encodes a string to Base64 format. + */ +export const toBase64 = (str: string | null | undefined): string => { + if (!str) return ''; + if (typeof Buffer !== 'undefined') { + return Buffer.from(str).toString('base64'); + } + + if (typeof btoa !== 'undefined') { + return btoa(str); + } + + throw new IntercomError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined'); +}; + +export function isObj(obj: unknown): obj is Record { + return obj != null && typeof obj === 'object' && !Array.isArray(obj); +} diff --git a/src/core/auth/AuthProvider.ts b/src/core/auth/AuthProvider.ts deleted file mode 100644 index 895a50ff..00000000 --- a/src/core/auth/AuthProvider.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { EndpointMetadata } from "../fetcher/EndpointMetadata.js"; -import type { AuthRequest } from "./AuthRequest.js"; - -export interface AuthProvider { - getAuthRequest(arg?: { endpointMetadata?: EndpointMetadata }): Promise; -} diff --git a/src/core/auth/AuthRequest.ts b/src/core/auth/AuthRequest.ts deleted file mode 100644 index f6218b42..00000000 --- a/src/core/auth/AuthRequest.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Request parameters for authentication requests. - */ -export interface AuthRequest { - /** - * The headers to be included in the request. - */ - headers: Record; -} diff --git a/src/core/auth/BasicAuth.ts b/src/core/auth/BasicAuth.ts deleted file mode 100644 index a6423591..00000000 --- a/src/core/auth/BasicAuth.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { base64Decode, base64Encode } from "../base64.js"; - -export interface BasicAuth { - username: string; - password: string; -} - -const BASIC_AUTH_HEADER_PREFIX = /^Basic /i; - -export const BasicAuth = { - toAuthorizationHeader: (basicAuth: BasicAuth | undefined): string | undefined => { - if (basicAuth == null) { - return undefined; - } - const token = base64Encode(`${basicAuth.username}:${basicAuth.password}`); - return `Basic ${token}`; - }, - fromAuthorizationHeader: (header: string): BasicAuth => { - const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, ""); - const decoded = base64Decode(credentials); - const [username, ...passwordParts] = decoded.split(":"); - const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined; - - if (username == null || password == null) { - throw new Error("Invalid basic auth"); - } - return { - username, - password, - }; - }, -}; diff --git a/src/core/auth/BearerToken.ts b/src/core/auth/BearerToken.ts deleted file mode 100644 index c44a06c3..00000000 --- a/src/core/auth/BearerToken.ts +++ /dev/null @@ -1,20 +0,0 @@ -export type BearerToken = string; - -const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i; - -function toAuthorizationHeader(token: string | undefined): string | undefined { - if (token == null) { - return undefined; - } - return `Bearer ${token}`; -} - -export const BearerToken: { - toAuthorizationHeader: typeof toAuthorizationHeader; - fromAuthorizationHeader: (header: string) => BearerToken; -} = { - toAuthorizationHeader: toAuthorizationHeader, - fromAuthorizationHeader: (header: string): BearerToken => { - return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim() as BearerToken; - }, -}; diff --git a/src/core/auth/NoOpAuthProvider.ts b/src/core/auth/NoOpAuthProvider.ts deleted file mode 100644 index 5b7acfd2..00000000 --- a/src/core/auth/NoOpAuthProvider.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { AuthProvider } from "./AuthProvider.js"; -import type { AuthRequest } from "./AuthRequest.js"; - -export class NoOpAuthProvider implements AuthProvider { - public getAuthRequest(): Promise { - return Promise.resolve({ headers: {} }); - } -} diff --git a/src/core/auth/index.ts b/src/core/auth/index.ts deleted file mode 100644 index 2215b227..00000000 --- a/src/core/auth/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export type { AuthProvider } from "./AuthProvider.js"; -export type { AuthRequest } from "./AuthRequest.js"; -export { BasicAuth } from "./BasicAuth.js"; -export { BearerToken } from "./BearerToken.js"; -export { NoOpAuthProvider } from "./NoOpAuthProvider.js"; diff --git a/src/core/base64.ts b/src/core/base64.ts deleted file mode 100644 index 448a0db6..00000000 --- a/src/core/base64.ts +++ /dev/null @@ -1,27 +0,0 @@ -function base64ToBytes(base64: string): Uint8Array { - const binString = atob(base64); - return Uint8Array.from(binString, (m) => m.codePointAt(0)!); -} - -function bytesToBase64(bytes: Uint8Array): string { - const binString = String.fromCodePoint(...bytes); - return btoa(binString); -} - -export function base64Encode(input: string): string { - if (typeof Buffer !== "undefined") { - return Buffer.from(input, "utf8").toString("base64"); - } - - const bytes = new TextEncoder().encode(input); - return bytesToBase64(bytes); -} - -export function base64Decode(input: string): string { - if (typeof Buffer !== "undefined") { - return Buffer.from(input, "base64").toString("utf8"); - } - - const bytes = base64ToBytes(input); - return new TextDecoder().decode(bytes); -} diff --git a/src/core/exports.ts b/src/core/exports.ts deleted file mode 100644 index d2774491..00000000 --- a/src/core/exports.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./logging/exports.js"; -export * from "./pagination/exports.js"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts deleted file mode 100644 index 97ab83c2..00000000 --- a/src/core/fetcher/APIResponse.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { RawResponse } from "./RawResponse.js"; - -/** - * 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/BinaryResponse.ts b/src/core/fetcher/BinaryResponse.ts deleted file mode 100644 index bca7f4c7..00000000 --- a/src/core/fetcher/BinaryResponse.ts +++ /dev/null @@ -1,34 +0,0 @@ -export type BinaryResponse = { - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ - bodyUsed: Response["bodyUsed"]; - /** - * Returns a ReadableStream of the response body. - * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) - */ - stream: () => Response["body"]; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ - arrayBuffer: () => ReturnType; - /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ - blob: () => ReturnType; - /** - * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) - * Some versions of the Fetch API may not support this method. - */ - bytes?(): ReturnType; -}; - -export function getBinaryResponse(response: Response): BinaryResponse { - const binaryResponse: BinaryResponse = { - get bodyUsed() { - return response.bodyUsed; - }, - stream: () => response.body, - arrayBuffer: response.arrayBuffer.bind(response), - blob: response.blob.bind(response), - }; - if ("bytes" in response && typeof response.bytes === "function") { - binaryResponse.bytes = response.bytes.bind(response); - } - - return binaryResponse; -} diff --git a/src/core/fetcher/EndpointMetadata.ts b/src/core/fetcher/EndpointMetadata.ts deleted file mode 100644 index 998d68f5..00000000 --- a/src/core/fetcher/EndpointMetadata.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type SecuritySchemeKey = string; -/** - * A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme. - * All schemes in the collection must be satisfied for authentication to be successful. - */ -export type SecuritySchemeCollection = Record; -export type AuthScope = string; -export type EndpointMetadata = { - /** - * An array of security scheme collections. Each collection represents an alternative way to authenticate. - */ - security?: SecuritySchemeCollection[]; -}; diff --git a/src/core/fetcher/EndpointSupplier.ts b/src/core/fetcher/EndpointSupplier.ts deleted file mode 100644 index 8079841c..00000000 --- a/src/core/fetcher/EndpointSupplier.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { EndpointMetadata } from "./EndpointMetadata.js"; -import type { Supplier } from "./Supplier.js"; - -type EndpointSupplierFn = (arg: { endpointMetadata: EndpointMetadata }) => T | Promise; -export type EndpointSupplier = Supplier | EndpointSupplierFn; -export const EndpointSupplier = { - get: async (supplier: EndpointSupplier, arg: { endpointMetadata: EndpointMetadata }): Promise => { - if (typeof supplier === "function") { - return (supplier as EndpointSupplierFn)(arg); - } else { - return supplier; - } - }, -}; diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts deleted file mode 100644 index 58bb0e3e..00000000 --- a/src/core/fetcher/Fetcher.ts +++ /dev/null @@ -1,391 +0,0 @@ -import { toJson } from "../json.js"; -import { createLogger, type LogConfig, type Logger } from "../logging/logger.js"; -import type { APIResponse } from "./APIResponse.js"; -import { createRequestUrl } from "./createRequestUrl.js"; -import type { EndpointMetadata } from "./EndpointMetadata.js"; -import { EndpointSupplier } from "./EndpointSupplier.js"; -import { getErrorResponseBody } from "./getErrorResponseBody.js"; -import { getFetchFn } from "./getFetchFn.js"; -import { getRequestBody } from "./getRequestBody.js"; -import { getResponseBody } from "./getResponseBody.js"; -import { Headers } from "./Headers.js"; -import { makeRequest } from "./makeRequest.js"; -import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js"; -import { requestWithRetries } from "./requestWithRetries.js"; - -export type FetchFunction = (args: Fetcher.Args) => Promise>; - -export declare namespace Fetcher { - export interface Args { - url: string; - method: string; - contentType?: string; - headers?: Record | null | undefined>; - queryParameters?: Record; - body?: unknown; - timeoutMs?: number; - maxRetries?: number; - withCredentials?: boolean; - abortSignal?: AbortSignal; - requestType?: "json" | "file" | "bytes" | "form" | "other"; - responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response"; - duplex?: "half"; - endpointMetadata?: EndpointMetadata; - fetchFn?: typeof fetch; - logging?: LogConfig | Logger; - } - - export type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError; - - export interface FailedStatusCodeError { - reason: "status-code"; - statusCode: number; - body: unknown; - } - - export interface NonJsonError { - reason: "non-json"; - statusCode: number; - rawBody: string; - } - - export interface BodyIsNullError { - reason: "body-is-null"; - statusCode: number; - } - - export interface TimeoutError { - reason: "timeout"; - } - - export interface UnknownError { - reason: "unknown"; - errorMessage: string; - } -} - -const SENSITIVE_HEADERS = new Set([ - "authorization", - "www-authenticate", - "x-api-key", - "api-key", - "apikey", - "x-api-token", - "x-auth-token", - "auth-token", - "cookie", - "set-cookie", - "proxy-authorization", - "proxy-authenticate", - "x-csrf-token", - "x-xsrf-token", - "x-session-token", - "x-access-token", -]); - -function redactHeaders(headers: Headers | Record): Record { - const filtered: Record = {}; - for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) { - if (SENSITIVE_HEADERS.has(key.toLowerCase())) { - filtered[key] = "[REDACTED]"; - } else { - filtered[key] = value; - } - } - return filtered; -} - -const SENSITIVE_QUERY_PARAMS = new Set([ - "api_key", - "api-key", - "apikey", - "token", - "access_token", - "access-token", - "auth_token", - "auth-token", - "password", - "passwd", - "secret", - "api_secret", - "api-secret", - "apisecret", - "key", - "session", - "session_id", - "session-id", -]); - -function redactQueryParameters(queryParameters?: Record): Record | undefined { - if (queryParameters == null) { - return queryParameters; - } - const redacted: Record = {}; - for (const [key, value] of Object.entries(queryParameters)) { - if (SENSITIVE_QUERY_PARAMS.has(key.toLowerCase())) { - redacted[key] = "[REDACTED]"; - } else { - redacted[key] = value; - } - } - return redacted; -} - -function redactUrl(url: string): string { - const protocolIndex = url.indexOf("://"); - if (protocolIndex === -1) return url; - - const afterProtocol = protocolIndex + 3; - - // Find the first delimiter that marks the end of the authority section - const pathStart = url.indexOf("/", afterProtocol); - let queryStart = url.indexOf("?", afterProtocol); - let fragmentStart = url.indexOf("#", afterProtocol); - - const firstDelimiter = Math.min( - pathStart === -1 ? url.length : pathStart, - queryStart === -1 ? url.length : queryStart, - fragmentStart === -1 ? url.length : fragmentStart, - ); - - // Find the LAST @ before the delimiter (handles multiple @ in credentials) - let atIndex = -1; - for (let i = afterProtocol; i < firstDelimiter; i++) { - if (url[i] === "@") { - atIndex = i; - } - } - - if (atIndex !== -1) { - url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`; - } - - // Recalculate queryStart since url might have changed - queryStart = url.indexOf("?"); - if (queryStart === -1) return url; - - fragmentStart = url.indexOf("#", queryStart); - const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length; - const queryString = url.slice(queryStart + 1, queryEnd); - - if (queryString.length === 0) return url; - - // FAST PATH: Quick check if any sensitive keywords present - // Using indexOf is faster than regex for simple substring matching - const lower = queryString.toLowerCase(); - const hasSensitive = - lower.includes("token") || - lower.includes("key") || - lower.includes("password") || - lower.includes("passwd") || - lower.includes("secret") || - lower.includes("session") || - lower.includes("auth"); - - if (!hasSensitive) { - return url; - } - - // SLOW PATH: Parse and redact - const redactedParams: string[] = []; - const params = queryString.split("&"); - - for (const param of params) { - const equalIndex = param.indexOf("="); - if (equalIndex === -1) { - redactedParams.push(param); - continue; - } - - const key = param.slice(0, equalIndex); - let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()); - - if (!shouldRedact && key.includes("%")) { - try { - const decodedKey = decodeURIComponent(key); - shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase()); - } catch {} - } - - redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param); - } - - return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd); -} - -async function getHeaders(args: Fetcher.Args): Promise { - const newHeaders: Headers = new Headers(); - - newHeaders.set( - "Accept", - args.responseType === "json" ? "application/json" : args.responseType === "text" ? "text/plain" : "*/*", - ); - if (args.body !== undefined && args.contentType != null) { - newHeaders.set("Content-Type", args.contentType); - } - - if (args.headers == null) { - return newHeaders; - } - - for (const [key, value] of Object.entries(args.headers)) { - const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} }); - if (typeof result === "string") { - newHeaders.set(key, result); - continue; - } - if (result == null) { - continue; - } - newHeaders.set(key, `${result}`); - } - return newHeaders; -} - -export async function fetcherImpl(args: Fetcher.Args): Promise> { - const url = createRequestUrl(args.url, args.queryParameters); - const requestBody: BodyInit | undefined = await getRequestBody({ - body: args.body, - type: args.requestType ?? "other", - }); - const fetchFn = args.fetchFn ?? (await getFetchFn()); - const headers = await getHeaders(args); - const logger = createLogger(args.logging); - - if (logger.isDebug()) { - const metadata = { - method: args.method, - url: redactUrl(url), - headers: redactHeaders(headers), - queryParameters: redactQueryParameters(args.queryParameters), - hasBody: requestBody != null, - }; - logger.debug("Making HTTP request", metadata); - } - - try { - const response = await requestWithRetries( - async () => - makeRequest( - fetchFn, - url, - args.method, - headers, - requestBody, - args.timeoutMs, - args.abortSignal, - args.withCredentials, - args.duplex, - ), - args.maxRetries, - ); - - if (response.status >= 200 && response.status < 400) { - if (logger.isDebug()) { - const metadata = { - method: args.method, - url: redactUrl(url), - statusCode: response.status, - responseHeaders: redactHeaders(response.headers), - }; - logger.debug("HTTP request succeeded", metadata); - } - const body = await getResponseBody(response, args.responseType); - return { - ok: true, - body: body as R, - headers: response.headers, - rawResponse: toRawResponse(response), - }; - } else { - if (logger.isError()) { - const metadata = { - method: args.method, - url: redactUrl(url), - statusCode: response.status, - responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())), - }; - logger.error("HTTP request failed with error status", metadata); - } - return { - ok: false, - error: { - reason: "status-code", - statusCode: response.status, - body: await getErrorResponseBody(response), - }, - rawResponse: toRawResponse(response), - }; - } - } catch (error) { - if (args.abortSignal?.aborted) { - if (logger.isError()) { - const metadata = { - method: args.method, - url: redactUrl(url), - }; - logger.error("HTTP request was aborted", metadata); - } - return { - ok: false, - error: { - reason: "unknown", - errorMessage: "The user aborted a request", - }, - rawResponse: abortRawResponse, - }; - } else if (error instanceof Error && error.name === "AbortError") { - if (logger.isError()) { - const metadata = { - method: args.method, - url: redactUrl(url), - timeoutMs: args.timeoutMs, - }; - logger.error("HTTP request timed out", metadata); - } - return { - ok: false, - error: { - reason: "timeout", - }, - rawResponse: abortRawResponse, - }; - } else if (error instanceof Error) { - if (logger.isError()) { - const metadata = { - method: args.method, - url: redactUrl(url), - errorMessage: error.message, - }; - logger.error("HTTP request failed with error", metadata); - } - return { - ok: false, - error: { - reason: "unknown", - errorMessage: error.message, - }, - rawResponse: unknownRawResponse, - }; - } - - if (logger.isError()) { - const metadata = { - method: args.method, - url: redactUrl(url), - error: toJson(error), - }; - logger.error("HTTP request failed with unknown error", metadata); - } - return { - ok: false, - error: { - reason: "unknown", - errorMessage: toJson(error), - }, - rawResponse: unknownRawResponse, - }; - } -} - -export const fetcher: FetchFunction = fetcherImpl; diff --git a/src/core/fetcher/Headers.ts b/src/core/fetcher/Headers.ts deleted file mode 100644 index af841aa2..00000000 --- a/src/core/fetcher/Headers.ts +++ /dev/null @@ -1,93 +0,0 @@ -let Headers: typeof globalThis.Headers; - -if (typeof globalThis.Headers !== "undefined") { - Headers = globalThis.Headers; -} else { - Headers = class Headers implements Headers { - private headers: Map; - - 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 deleted file mode 100644 index 692ca7d7..00000000 --- a/src/core/fetcher/HttpResponsePromise.ts +++ /dev/null @@ -1,116 +0,0 @@ -import type { WithRawResponse } from "./RawResponse.js"; - -/** - * 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 deleted file mode 100644 index 37fb44e2..00000000 --- a/src/core/fetcher/RawResponse.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Headers } from "./Headers.js"; - -/** - * 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/Supplier.ts b/src/core/fetcher/Supplier.ts deleted file mode 100644 index 867c931c..00000000 --- a/src/core/fetcher/Supplier.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type Supplier = T | Promise | (() => T | Promise); - -export const Supplier = { - get: async (supplier: Supplier): Promise => { - if (typeof supplier === "function") { - return (supplier as () => T)(); - } else { - return supplier; - } - }, -}; diff --git a/src/core/fetcher/createRequestUrl.ts b/src/core/fetcher/createRequestUrl.ts deleted file mode 100644 index 88e13265..00000000 --- a/src/core/fetcher/createRequestUrl.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { toQueryString } from "../url/qs.js"; - -export function createRequestUrl(baseUrl: string, queryParameters?: Record): string { - const queryString = toQueryString(queryParameters, { arrayFormat: "repeat" }); - return queryString ? `${baseUrl}?${queryString}` : baseUrl; -} diff --git a/src/core/fetcher/getErrorResponseBody.ts b/src/core/fetcher/getErrorResponseBody.ts deleted file mode 100644 index 7cf4e623..00000000 --- a/src/core/fetcher/getErrorResponseBody.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { fromJson } from "../json.js"; -import { getResponseBody } from "./getResponseBody.js"; - -export async function getErrorResponseBody(response: Response): Promise { - let contentType = response.headers.get("Content-Type")?.toLowerCase(); - if (contentType == null || contentType.length === 0) { - return getResponseBody(response); - } - - if (contentType.indexOf(";") !== -1) { - contentType = contentType.split(";")[0]?.trim() ?? ""; - } - switch (contentType) { - case "application/hal+json": - case "application/json": - case "application/ld+json": - case "application/problem+json": - case "application/vnd.api+json": - case "text/json": { - const text = await response.text(); - return text.length > 0 ? fromJson(text) : undefined; - } - default: - if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) { - const text = await response.text(); - return text.length > 0 ? fromJson(text) : undefined; - } - - // Fallback to plain text if content type is not recognized - // Even if no body is present, the response will be an empty string - return await response.text(); - } -} diff --git a/src/core/fetcher/getFetchFn.ts b/src/core/fetcher/getFetchFn.ts deleted file mode 100644 index 9f845b95..00000000 --- a/src/core/fetcher/getFetchFn.ts +++ /dev/null @@ -1,3 +0,0 @@ -export async function getFetchFn(): Promise { - return fetch; -} diff --git a/src/core/fetcher/getHeader.ts b/src/core/fetcher/getHeader.ts deleted file mode 100644 index 50f922b0..00000000 --- a/src/core/fetcher/getHeader.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function getHeader(headers: Record, header: string): string | undefined { - for (const [headerKey, headerValue] of Object.entries(headers)) { - if (headerKey.toLowerCase() === header.toLowerCase()) { - return headerValue; - } - } - return undefined; -} diff --git a/src/core/fetcher/getRequestBody.ts b/src/core/fetcher/getRequestBody.ts deleted file mode 100644 index 91d9d81f..00000000 --- a/src/core/fetcher/getRequestBody.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { toJson } from "../json.js"; -import { toQueryString } from "../url/qs.js"; - -export declare namespace GetRequestBody { - interface Args { - body: unknown; - type: "json" | "file" | "bytes" | "form" | "other"; - } -} - -export async function getRequestBody({ body, type }: GetRequestBody.Args): Promise { - if (type === "form") { - return toQueryString(body, { arrayFormat: "repeat", encode: true }); - } - if (type.includes("json")) { - return toJson(body); - } else { - return body as BodyInit; - } -} diff --git a/src/core/fetcher/getResponseBody.ts b/src/core/fetcher/getResponseBody.ts deleted file mode 100644 index 708d5572..00000000 --- a/src/core/fetcher/getResponseBody.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { fromJson } from "../json.js"; -import { getBinaryResponse } from "./BinaryResponse.js"; - -export async function getResponseBody(response: Response, responseType?: string): Promise { - switch (responseType) { - case "binary-response": - return getBinaryResponse(response); - case "blob": - return await response.blob(); - case "arrayBuffer": - return await response.arrayBuffer(); - case "sse": - if (response.body == null) { - return { - ok: false, - error: { - reason: "body-is-null", - statusCode: response.status, - }, - }; - } - return response.body; - case "streaming": - if (response.body == null) { - return { - ok: false, - error: { - reason: "body-is-null", - statusCode: response.status, - }, - }; - } - - return response.body; - - case "text": - return await response.text(); - } - - // if responseType is "json" or not specified, try to parse as JSON - const text = await response.text(); - if (text.length > 0) { - try { - const responseBody = fromJson(text); - return responseBody; - } catch (_err) { - return { - ok: false, - error: { - reason: "non-json", - statusCode: response.status, - rawBody: text, - }, - }; - } - } - return undefined; -} diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts deleted file mode 100644 index c3bc6da2..00000000 --- a/src/core/fetcher/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export type { APIResponse } from "./APIResponse.js"; -export type { BinaryResponse } from "./BinaryResponse.js"; -export type { EndpointMetadata } from "./EndpointMetadata.js"; -export { EndpointSupplier } from "./EndpointSupplier.js"; -export type { Fetcher, FetchFunction } from "./Fetcher.js"; -export { fetcher } from "./Fetcher.js"; -export { getHeader } from "./getHeader.js"; -export { HttpResponsePromise } from "./HttpResponsePromise.js"; -export type { RawResponse, WithRawResponse } from "./RawResponse.js"; -export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js"; -export { Supplier } from "./Supplier.js"; diff --git a/src/core/fetcher/makeRequest.ts b/src/core/fetcher/makeRequest.ts deleted file mode 100644 index 921565eb..00000000 --- a/src/core/fetcher/makeRequest.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { anySignal, getTimeoutSignal } from "./signals.js"; - -export const makeRequest = async ( - fetchFn: (url: string, init: RequestInit) => Promise, - url: string, - method: string, - headers: Headers | Record, - requestBody: BodyInit | undefined, - timeoutMs?: number, - abortSignal?: AbortSignal, - withCredentials?: boolean, - duplex?: "half", -): Promise => { - const signals: AbortSignal[] = []; - - let timeoutAbortId: ReturnType | undefined; - if (timeoutMs != null) { - const { signal, abortId } = getTimeoutSignal(timeoutMs); - timeoutAbortId = abortId; - signals.push(signal); - } - - if (abortSignal != null) { - signals.push(abortSignal); - } - const newSignals = anySignal(signals); - const response = await fetchFn(url, { - method: method, - headers, - body: requestBody, - signal: newSignals, - credentials: withCredentials ? "include" : undefined, - // @ts-ignore - duplex, - }); - - if (timeoutAbortId != null) { - clearTimeout(timeoutAbortId); - } - - return response; -}; diff --git a/src/core/fetcher/requestWithRetries.ts b/src/core/fetcher/requestWithRetries.ts deleted file mode 100644 index 1f689688..00000000 --- a/src/core/fetcher/requestWithRetries.ts +++ /dev/null @@ -1,64 +0,0 @@ -const INITIAL_RETRY_DELAY = 1000; // in milliseconds -const MAX_RETRY_DELAY = 60000; // in milliseconds -const DEFAULT_MAX_RETRIES = 2; -const JITTER_FACTOR = 0.2; // 20% random jitter - -function addPositiveJitter(delay: number): number { - const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR; - return delay * jitterMultiplier; -} - -function addSymmetricJitter(delay: number): number { - const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR; - return delay * jitterMultiplier; -} - -function getRetryDelayFromHeaders(response: Response, retryAttempt: number): number { - const retryAfter = response.headers.get("Retry-After"); - if (retryAfter) { - const retryAfterSeconds = parseInt(retryAfter, 10); - if (!Number.isNaN(retryAfterSeconds) && retryAfterSeconds > 0) { - return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY); - } - - const retryAfterDate = new Date(retryAfter); - if (!Number.isNaN(retryAfterDate.getTime())) { - const delay = retryAfterDate.getTime() - Date.now(); - if (delay > 0) { - return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY); - } - } - } - - const rateLimitReset = response.headers.get("X-RateLimit-Reset"); - if (rateLimitReset) { - const resetTime = parseInt(rateLimitReset, 10); - if (!Number.isNaN(resetTime)) { - const delay = resetTime * 1000 - Date.now(); - if (delay > 0) { - return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY)); - } - } - } - - return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * 2 ** retryAttempt, MAX_RETRY_DELAY)); -} - -export async function requestWithRetries( - requestFn: () => Promise, - maxRetries: number = DEFAULT_MAX_RETRIES, -): Promise { - let response: Response = await requestFn(); - - for (let i = 0; i < maxRetries; ++i) { - if ([408, 429].includes(response.status) || response.status >= 500) { - const delay = getRetryDelayFromHeaders(response, i); - - await new Promise((resolve) => setTimeout(resolve, delay)); - response = await requestFn(); - } else { - break; - } - } - return response!; -} diff --git a/src/core/fetcher/signals.ts b/src/core/fetcher/signals.ts deleted file mode 100644 index 7bd3757e..00000000 --- a/src/core/fetcher/signals.ts +++ /dev/null @@ -1,26 +0,0 @@ -const TIMEOUT = "timeout"; - -export function getTimeoutSignal(timeoutMs: number): { signal: AbortSignal; abortId: ReturnType } { - const controller = new AbortController(); - const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs); - return { signal: controller.signal, abortId }; -} - -export function anySignal(...args: AbortSignal[] | [AbortSignal[]]): AbortSignal { - const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args) as AbortSignal[]; - - const controller = new AbortController(); - - for (const signal of signals) { - if (signal.aborted) { - controller.abort((signal as any)?.reason); - break; - } - - signal.addEventListener("abort", () => controller.abort((signal as any)?.reason), { - signal: controller.signal, - }); - } - - return controller.signal; -} diff --git a/src/core/headers.ts b/src/core/headers.ts deleted file mode 100644 index 78ed8b50..00000000 --- a/src/core/headers.ts +++ /dev/null @@ -1,35 +0,0 @@ -export function mergeHeaders( - ...headersArray: (Record | null | undefined)[] -): Record { - const result: Record = {}; - - for (const [key, value] of headersArray - .filter((headers) => headers != null) - .flatMap((headers) => Object.entries(headers))) { - const insensitiveKey = key.toLowerCase(); - if (value != null) { - result[insensitiveKey] = value; - } else if (insensitiveKey in result) { - delete result[insensitiveKey]; - } - } - - return result; -} - -export function mergeOnlyDefinedHeaders( - ...headersArray: (Record | null | undefined)[] -): Record { - const result: Record = {}; - - for (const [key, value] of headersArray - .filter((headers) => headers != null) - .flatMap((headers) => Object.entries(headers))) { - const insensitiveKey = key.toLowerCase(); - if (value != null) { - result[insensitiveKey] = value; - } - } - - return result; -} diff --git a/src/core/index.ts b/src/core/index.ts deleted file mode 100644 index f25662a5..00000000 --- a/src/core/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export * from "./auth/index.js"; -export * from "./base64.js"; -export * from "./fetcher/index.js"; -export * as logging from "./logging/index.js"; -export * from "./pagination/index.js"; -export * from "./runtime/index.js"; -export * as url from "./url/index.js"; -export * from "./utils/index.js"; diff --git a/src/core/json.ts b/src/core/json.ts deleted file mode 100644 index c052f324..00000000 --- a/src/core/json.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Serialize a value to JSON - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - * @returns JSON string - */ -export const toJson = ( - value: unknown, - replacer?: (this: unknown, key: string, value: unknown) => unknown, - space?: string | number, -): string => { - return JSON.stringify(value, replacer, space); -}; - -/** - * Parse JSON string to object, array, or other type - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is. - * @returns Parsed object, array, or other type - */ -export function fromJson( - text: string, - reviver?: (this: unknown, key: string, value: unknown) => unknown, -): T { - return JSON.parse(text, reviver); -} diff --git a/src/core/logging/exports.ts b/src/core/logging/exports.ts deleted file mode 100644 index 88f6c00d..00000000 --- a/src/core/logging/exports.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as logger from "./logger.js"; - -export namespace logging { - /** - * Configuration for logger instances. - */ - export type LogConfig = logger.LogConfig; - export type LogLevel = logger.LogLevel; - export const LogLevel: typeof logger.LogLevel = logger.LogLevel; - export type ILogger = logger.ILogger; - /** - * Console logger implementation that outputs to the console. - */ - export type ConsoleLogger = logger.ConsoleLogger; - /** - * Console logger implementation that outputs to the console. - */ - export const ConsoleLogger: typeof logger.ConsoleLogger = logger.ConsoleLogger; -} diff --git a/src/core/logging/index.ts b/src/core/logging/index.ts deleted file mode 100644 index d81cc32c..00000000 --- a/src/core/logging/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./logger.js"; diff --git a/src/core/logging/logger.ts b/src/core/logging/logger.ts deleted file mode 100644 index a3f3673c..00000000 --- a/src/core/logging/logger.ts +++ /dev/null @@ -1,203 +0,0 @@ -export const LogLevel = { - Debug: "debug", - Info: "info", - Warn: "warn", - Error: "error", -} as const; -export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel]; -const logLevelMap: Record = { - [LogLevel.Debug]: 1, - [LogLevel.Info]: 2, - [LogLevel.Warn]: 3, - [LogLevel.Error]: 4, -}; - -export interface ILogger { - /** - * Logs a debug message. - * @param message - The message to log - * @param args - Additional arguments to log - */ - debug(message: string, ...args: unknown[]): void; - /** - * Logs an info message. - * @param message - The message to log - * @param args - Additional arguments to log - */ - info(message: string, ...args: unknown[]): void; - /** - * Logs a warning message. - * @param message - The message to log - * @param args - Additional arguments to log - */ - warn(message: string, ...args: unknown[]): void; - /** - * Logs an error message. - * @param message - The message to log - * @param args - Additional arguments to log - */ - error(message: string, ...args: unknown[]): void; -} - -/** - * Configuration for logger initialization. - */ -export interface LogConfig { - /** - * Minimum log level to output. - * @default LogLevel.Info - */ - level?: LogLevel; - /** - * Logger implementation to use. - * @default new ConsoleLogger() - */ - logger?: ILogger; - /** - * Whether logging should be silenced. - * @default true - */ - silent?: boolean; -} - -/** - * Default console-based logger implementation. - */ -export class ConsoleLogger implements ILogger { - debug(message: string, ...args: unknown[]): void { - console.debug(message, ...args); - } - info(message: string, ...args: unknown[]): void { - console.info(message, ...args); - } - warn(message: string, ...args: unknown[]): void { - console.warn(message, ...args); - } - error(message: string, ...args: unknown[]): void { - console.error(message, ...args); - } -} - -/** - * Logger class that provides level-based logging functionality. - */ -export class Logger { - private readonly level: number; - private readonly logger: ILogger; - private readonly silent: boolean; - - /** - * Creates a new logger instance. - * @param config - Logger configuration - */ - constructor(config: Required) { - this.level = logLevelMap[config.level]; - this.logger = config.logger; - this.silent = config.silent; - } - - /** - * Checks if a log level should be output based on configuration. - * @param level - The log level to check - * @returns True if the level should be logged - */ - public shouldLog(level: LogLevel): boolean { - return !this.silent && this.level <= logLevelMap[level]; - } - - /** - * Checks if debug logging is enabled. - * @returns True if debug logs should be output - */ - public isDebug(): boolean { - return this.shouldLog(LogLevel.Debug); - } - - /** - * Logs a debug message if debug logging is enabled. - * @param message - The message to log - * @param args - Additional arguments to log - */ - public debug(message: string, ...args: unknown[]): void { - if (this.isDebug()) { - this.logger.debug(message, ...args); - } - } - - /** - * Checks if info logging is enabled. - * @returns True if info logs should be output - */ - public isInfo(): boolean { - return this.shouldLog(LogLevel.Info); - } - - /** - * Logs an info message if info logging is enabled. - * @param message - The message to log - * @param args - Additional arguments to log - */ - public info(message: string, ...args: unknown[]): void { - if (this.isInfo()) { - this.logger.info(message, ...args); - } - } - - /** - * Checks if warning logging is enabled. - * @returns True if warning logs should be output - */ - public isWarn(): boolean { - return this.shouldLog(LogLevel.Warn); - } - - /** - * Logs a warning message if warning logging is enabled. - * @param message - The message to log - * @param args - Additional arguments to log - */ - public warn(message: string, ...args: unknown[]): void { - if (this.isWarn()) { - this.logger.warn(message, ...args); - } - } - - /** - * Checks if error logging is enabled. - * @returns True if error logs should be output - */ - public isError(): boolean { - return this.shouldLog(LogLevel.Error); - } - - /** - * Logs an error message if error logging is enabled. - * @param message - The message to log - * @param args - Additional arguments to log - */ - public error(message: string, ...args: unknown[]): void { - if (this.isError()) { - this.logger.error(message, ...args); - } - } -} - -export function createLogger(config?: LogConfig | Logger): Logger { - if (config == null) { - return defaultLogger; - } - if (config instanceof Logger) { - return config; - } - config = config ?? {}; - config.level ??= LogLevel.Info; - config.logger ??= new ConsoleLogger(); - config.silent ??= true; - return new Logger(config as Required); -} - -const defaultLogger: Logger = new Logger({ - level: LogLevel.Info, - logger: new ConsoleLogger(), - silent: true, -}); diff --git a/src/core/pagination/Page.ts b/src/core/pagination/Page.ts deleted file mode 100644 index 6621a6f1..00000000 --- a/src/core/pagination/Page.ts +++ /dev/null @@ -1,76 +0,0 @@ -import type { HttpResponsePromise, RawResponse } from "../fetcher/index.js"; - -/** - * A page of results from a paginated API. - * - * @template T The type of the items in the page. - * @template R The type of the API response. - */ -export class Page implements AsyncIterable { - public data: T[]; - public rawResponse: RawResponse; - public response: R; - - private _hasNextPage: (response: R) => boolean; - private getItems: (response: R) => T[]; - private loadNextPage: (response: R) => HttpResponsePromise; - - constructor({ - response, - rawResponse, - hasNextPage, - getItems, - loadPage, - }: { - response: R; - rawResponse: RawResponse; - hasNextPage: (response: R) => boolean; - getItems: (response: R) => T[]; - loadPage: (response: R) => HttpResponsePromise; - }) { - this.response = response; - this.rawResponse = rawResponse; - this.data = getItems(response); - this._hasNextPage = hasNextPage; - this.getItems = getItems; - this.loadNextPage = loadPage; - } - - /** - * Retrieves the next page - * @returns this - */ - public async getNextPage(): Promise { - const { data, rawResponse } = await this.loadNextPage(this.response).withRawResponse(); - this.response = data; - this.rawResponse = rawResponse; - this.data = this.getItems(this.response); - return this; - } - - /** - * @returns whether there is a next page to load - */ - public hasNextPage(): boolean { - return this._hasNextPage(this.response); - } - - private async *iterMessages(): AsyncGenerator { - for (const item of this.data) { - yield item; - } - - while (this.hasNextPage()) { - await this.getNextPage(); - for (const item of this.data) { - yield item; - } - } - } - - async *[Symbol.asyncIterator](): AsyncIterator { - for await (const message of this.iterMessages()) { - yield message; - } - } -} diff --git a/src/core/pagination/exports.ts b/src/core/pagination/exports.ts deleted file mode 100644 index d3acc60b..00000000 --- a/src/core/pagination/exports.ts +++ /dev/null @@ -1 +0,0 @@ -export type { Page } from "./Page.js"; diff --git a/src/core/pagination/index.ts b/src/core/pagination/index.ts deleted file mode 100644 index 7781cbd6..00000000 --- a/src/core/pagination/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Page } from "./Page.js"; diff --git a/src/core/runtime/index.ts b/src/core/runtime/index.ts deleted file mode 100644 index cfab23f9..00000000 --- a/src/core/runtime/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { RUNTIME } from "./runtime.js"; diff --git a/src/core/runtime/runtime.ts b/src/core/runtime/runtime.ts deleted file mode 100644 index 56ebbb87..00000000 --- a/src/core/runtime/runtime.ts +++ /dev/null @@ -1,134 +0,0 @@ -interface DenoGlobal { - version: { - deno: string; - }; -} - -interface BunGlobal { - version: string; -} - -declare const Deno: DenoGlobal | undefined; -declare const Bun: BunGlobal | undefined; -declare const EdgeRuntime: string | undefined; -declare const self: typeof globalThis.self & { - importScripts?: unknown; -}; - -/** - * A constant that indicates which environment and version the SDK is running in. - */ -export const RUNTIME: Runtime = evaluateRuntime(); - -export interface Runtime { - type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime"; - version?: string; - parsedVersion?: number; -} - -function evaluateRuntime(): Runtime { - /** - * A constant that indicates whether the environment the code is running is a Web Browser. - */ - const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined"; - if (isBrowser) { - return { - type: "browser", - version: window.navigator.userAgent, - }; - } - - /** - * A constant that indicates whether the environment the code is running is Cloudflare. - * https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent - */ - const isCloudflare = typeof globalThis !== "undefined" && globalThis?.navigator?.userAgent === "Cloudflare-Workers"; - if (isCloudflare) { - return { - type: "workerd", - }; - } - - /** - * A constant that indicates whether the environment the code is running is Edge Runtime. - * https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime - */ - const isEdgeRuntime = typeof EdgeRuntime === "string"; - if (isEdgeRuntime) { - return { - type: "edge-runtime", - }; - } - - /** - * A constant that indicates whether the environment the code is running is a Web Worker. - */ - const isWebWorker = - typeof self === "object" && - typeof self?.importScripts === "function" && - (self.constructor?.name === "DedicatedWorkerGlobalScope" || - self.constructor?.name === "ServiceWorkerGlobalScope" || - self.constructor?.name === "SharedWorkerGlobalScope"); - if (isWebWorker) { - return { - type: "web-worker", - }; - } - - /** - * A constant that indicates whether the environment the code is running is Deno. - * FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions - */ - const isDeno = - typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined"; - if (isDeno) { - return { - type: "deno", - version: Deno.version.deno, - }; - } - - /** - * A constant that indicates whether the environment the code is running is Bun.sh. - */ - const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"; - if (isBun) { - return { - type: "bun", - version: Bun.version, - }; - } - - /** - * A constant that indicates whether the environment the code is running is in React-Native. - * This check should come before Node.js detection since React Native may have a process polyfill. - * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js - */ - const isReactNative = typeof navigator !== "undefined" && navigator?.product === "ReactNative"; - if (isReactNative) { - return { - type: "react-native", - }; - } - - /** - * A constant that indicates whether the environment the code is running is Node.JS. - */ - const isNode = - typeof process !== "undefined" && - "version" in process && - !!process.version && - "versions" in process && - !!process.versions?.node; - if (isNode) { - return { - type: "node", - version: process.versions.node, - parsedVersion: Number(process.versions.node.split(".")[0]), - }; - } - - return { - type: "unknown", - }; -} diff --git a/src/core/url/encodePathParam.ts b/src/core/url/encodePathParam.ts deleted file mode 100644 index 19b90124..00000000 --- a/src/core/url/encodePathParam.ts +++ /dev/null @@ -1,18 +0,0 @@ -export function encodePathParam(param: unknown): string { - if (param === null) { - return "null"; - } - const typeofParam = typeof param; - switch (typeofParam) { - case "undefined": - return "undefined"; - case "string": - case "number": - case "boolean": - break; - default: - param = String(param); - break; - } - return encodeURIComponent(param as string | number | boolean); -} diff --git a/src/core/url/index.ts b/src/core/url/index.ts deleted file mode 100644 index f2e0fa2d..00000000 --- a/src/core/url/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { encodePathParam } from "./encodePathParam.js"; -export { join } from "./join.js"; -export { toQueryString } from "./qs.js"; diff --git a/src/core/url/join.ts b/src/core/url/join.ts deleted file mode 100644 index 7ca7daef..00000000 --- a/src/core/url/join.ts +++ /dev/null @@ -1,79 +0,0 @@ -export function join(base: string, ...segments: string[]): string { - if (!base) { - return ""; - } - - if (segments.length === 0) { - return base; - } - - if (base.includes("://")) { - let url: URL; - try { - url = new URL(base); - } catch { - return joinPath(base, ...segments); - } - - const lastSegment = segments[segments.length - 1]; - const shouldPreserveTrailingSlash = lastSegment?.endsWith("/"); - - for (const segment of segments) { - const cleanSegment = trimSlashes(segment); - if (cleanSegment) { - url.pathname = joinPathSegments(url.pathname, cleanSegment); - } - } - - if (shouldPreserveTrailingSlash && !url.pathname.endsWith("/")) { - url.pathname += "/"; - } - - return url.toString(); - } - - return joinPath(base, ...segments); -} - -function joinPath(base: string, ...segments: string[]): string { - if (segments.length === 0) { - return base; - } - - let result = base; - - const lastSegment = segments[segments.length - 1]; - const shouldPreserveTrailingSlash = lastSegment?.endsWith("/"); - - for (const segment of segments) { - const cleanSegment = trimSlashes(segment); - if (cleanSegment) { - result = joinPathSegments(result, cleanSegment); - } - } - - if (shouldPreserveTrailingSlash && !result.endsWith("/")) { - result += "/"; - } - - return result; -} - -function joinPathSegments(left: string, right: string): string { - if (left.endsWith("/")) { - return left + right; - } - return `${left}/${right}`; -} - -function trimSlashes(str: string): string { - if (!str) return str; - - let start = 0; - let end = str.length; - - if (str.startsWith("/")) start = 1; - if (str.endsWith("/")) end = str.length - 1; - - return start === 0 && end === str.length ? str : str.slice(start, end); -} diff --git a/src/core/url/qs.ts b/src/core/url/qs.ts deleted file mode 100644 index 13e89be9..00000000 --- a/src/core/url/qs.ts +++ /dev/null @@ -1,74 +0,0 @@ -interface QueryStringOptions { - arrayFormat?: "indices" | "repeat"; - encode?: boolean; -} - -const defaultQsOptions: Required = { - arrayFormat: "indices", - encode: true, -} as const; - -function encodeValue(value: unknown, shouldEncode: boolean): string { - if (value === undefined) { - return ""; - } - if (value === null) { - return ""; - } - const stringValue = String(value); - return shouldEncode ? encodeURIComponent(stringValue) : stringValue; -} - -function stringifyObject(obj: Record, prefix = "", options: Required): string[] { - const parts: string[] = []; - - for (const [key, value] of Object.entries(obj)) { - const fullKey = prefix ? `${prefix}[${key}]` : key; - - if (value === undefined) { - continue; - } - - if (Array.isArray(value)) { - if (value.length === 0) { - continue; - } - for (let i = 0; i < value.length; i++) { - const item = value[i]; - if (item === undefined) { - continue; - } - if (typeof item === "object" && !Array.isArray(item) && item !== null) { - const arrayKey = options.arrayFormat === "indices" ? `${fullKey}[${i}]` : fullKey; - parts.push(...stringifyObject(item as Record, arrayKey, options)); - } else { - const arrayKey = options.arrayFormat === "indices" ? `${fullKey}[${i}]` : fullKey; - const encodedKey = options.encode ? encodeURIComponent(arrayKey) : arrayKey; - parts.push(`${encodedKey}=${encodeValue(item, options.encode)}`); - } - } - } else if (typeof value === "object" && value !== null) { - if (Object.keys(value as Record).length === 0) { - continue; - } - parts.push(...stringifyObject(value as Record, fullKey, options)); - } else { - const encodedKey = options.encode ? encodeURIComponent(fullKey) : fullKey; - parts.push(`${encodedKey}=${encodeValue(value, options.encode)}`); - } - } - - return parts; -} - -export function toQueryString(obj: unknown, options?: QueryStringOptions): string { - if (obj == null || typeof obj !== "object") { - return ""; - } - - const parts = stringifyObject(obj as Record, "", { - ...defaultQsOptions, - ...options, - }); - return parts.join("&"); -} diff --git a/src/core/utils/index.ts b/src/core/utils/index.ts deleted file mode 100644 index 11ff8f25..00000000 --- a/src/core/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { setObjectProperty } from "./setObjectProperty.js"; diff --git a/src/core/utils/setObjectProperty.ts b/src/core/utils/setObjectProperty.ts deleted file mode 100644 index 5528af24..00000000 --- a/src/core/utils/setObjectProperty.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is - * inspired by Lodash's set function, but is simplified to accommodate our use case. - * For more details, see https://lodash.com/docs/4.17.15#set. - * - * @param object The object to modify. - * @param path The path of the property to set. - * @param value The value to set. - * @return Returns object. - */ -export function setObjectProperty(object: T, path: string, value: any): T { - if (object == null) { - return object; - } - - const keys: string[] = path.split("."); - if (keys.length === 0) { - // Invalid path; do nothing. - return object; - } - - let current: Record = object; - for (let i = 0; i < keys.length - 1; i++) { - const key = keys[i]; - if (key == null) { - // Unreachable. - continue; - } - if (!current[key] || typeof current[key] !== "object") { - current[key] = {}; - } - current = current[key] as Record; - } - - const lastKey = keys[keys.length - 1]; - if (lastKey == null) { - // Unreachable. - return object; - } - - current[lastKey] = value; - return object; -} diff --git a/src/environments.ts b/src/environments.ts deleted file mode 100644 index 752460d1..00000000 --- a/src/environments.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export const IntercomEnvironment = { - UsProduction: "https://api.intercom.io", - EuProduction: "https://api.eu.intercom.io", - AuProduction: "https://api.au.intercom.io", -} as const; - -export type IntercomEnvironment = - | typeof IntercomEnvironment.UsProduction - | typeof IntercomEnvironment.EuProduction - | typeof IntercomEnvironment.AuProduction; diff --git a/src/error.ts b/src/error.ts new file mode 100644 index 00000000..6a073c94 --- /dev/null +++ b/src/error.ts @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { castToError, Headers } from './core'; + +export class IntercomError extends Error {} + +export class APIError extends IntercomError { + readonly status: number | undefined; + readonly headers: Headers | undefined; + readonly error: Object | undefined; + + constructor( + status: number | undefined, + error: Object | undefined, + message: string | undefined, + headers: Headers | undefined, + ) { + super(`${APIError.makeMessage(status, error, message)}`); + this.status = status; + this.headers = headers; + this.error = error; + } + + private static makeMessage(status: number | undefined, error: any, message: string | undefined) { + const msg = + error?.message ? + typeof error.message === 'string' ? + error.message + : JSON.stringify(error.message) + : error ? JSON.stringify(error) + : message; + + if (status && msg) { + return `${status} ${msg}`; + } + if (status) { + return `${status} status code (no body)`; + } + if (msg) { + return msg; + } + return '(no status code or body)'; + } + + static generate( + status: number | undefined, + errorResponse: Object | undefined, + message: string | undefined, + headers: Headers | undefined, + ) { + if (!status) { + return new APIConnectionError({ cause: castToError(errorResponse) }); + } + + const error = errorResponse as Record; + + if (status === 400) { + return new BadRequestError(status, error, message, headers); + } + + if (status === 401) { + return new AuthenticationError(status, error, message, headers); + } + + if (status === 403) { + return new PermissionDeniedError(status, error, message, headers); + } + + if (status === 404) { + return new NotFoundError(status, error, message, headers); + } + + if (status === 409) { + return new ConflictError(status, error, message, headers); + } + + if (status === 422) { + return new UnprocessableEntityError(status, error, message, headers); + } + + if (status === 429) { + return new RateLimitError(status, error, message, headers); + } + + if (status >= 500) { + return new InternalServerError(status, error, message, headers); + } + + return new APIError(status, error, message, headers); + } +} + +export class APIUserAbortError extends APIError { + override readonly status: undefined = undefined; + + constructor({ message }: { message?: string } = {}) { + super(undefined, undefined, message || 'Request was aborted.', undefined); + } +} + +export class APIConnectionError extends APIError { + override readonly status: undefined = undefined; + + constructor({ message, cause }: { message?: string; cause?: Error | undefined }) { + super(undefined, undefined, message || 'Connection error.', undefined); + // in some environments the 'cause' property is already declared + // @ts-ignore + if (cause) this.cause = cause; + } +} + +export class APIConnectionTimeoutError extends APIConnectionError { + constructor({ message }: { message?: string } = {}) { + super({ message: message ?? 'Request timed out.' }); + } +} + +export class BadRequestError extends APIError { + override readonly status: 400 = 400; +} + +export class AuthenticationError extends APIError { + override readonly status: 401 = 401; +} + +export class PermissionDeniedError extends APIError { + override readonly status: 403 = 403; +} + +export class NotFoundError extends APIError { + override readonly status: 404 = 404; +} + +export class ConflictError extends APIError { + override readonly status: 409 = 409; +} + +export class UnprocessableEntityError extends APIError { + override readonly status: 422 = 422; +} + +export class RateLimitError extends APIError { + override readonly status: 429 = 429; +} + +export class InternalServerError extends APIError {} diff --git a/src/errors/IntercomError.ts b/src/errors/IntercomError.ts deleted file mode 100644 index de63f5e0..00000000 --- a/src/errors/IntercomError.ts +++ /dev/null @@ -1,53 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../core/index.js"; -import { toJson } from "../core/json.js"; - -export class IntercomError extends Error { - 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); - this.statusCode = statusCode; - this.body = body; - this.rawResponse = rawResponse; - } -} - -function buildMessage({ - message, - statusCode, - body, -}: { - message: string | undefined; - statusCode: number | undefined; - body: unknown | undefined; -}): string { - const lines: string[] = []; - if (message != null) { - lines.push(message); - } - - if (statusCode != null) { - lines.push(`Status code: ${statusCode.toString()}`); - } - - if (body != null) { - lines.push(`Body: ${toJson(body, undefined, 2)}`); - } - - return lines.join("\n"); -} diff --git a/src/errors/IntercomTimeoutError.ts b/src/errors/IntercomTimeoutError.ts deleted file mode 100644 index e0c388db..00000000 --- a/src/errors/IntercomTimeoutError.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export class IntercomTimeoutError extends Error { - constructor(message: string) { - super(message); - Object.setPrototypeOf(this, IntercomTimeoutError.prototype); - } -} diff --git a/src/errors/handleNonStatusCodeError.ts b/src/errors/handleNonStatusCodeError.ts deleted file mode 100644 index 75076b10..00000000 --- a/src/errors/handleNonStatusCodeError.ts +++ /dev/null @@ -1,37 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as core from "../core/index.js"; -import * as errors from "./index.js"; - -export function handleNonStatusCodeError( - error: core.Fetcher.Error, - rawResponse: core.RawResponse, - method: string, - path: string, -): never { - switch (error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: error.statusCode, - body: error.rawBody, - rawResponse: rawResponse, - }); - case "body-is-null": - throw new errors.IntercomError({ - statusCode: error.statusCode, - rawResponse: rawResponse, - }); - case "timeout": - throw new errors.IntercomTimeoutError(`Timeout exceeded when calling ${method} ${path}.`); - case "unknown": - throw new errors.IntercomError({ - message: error.errorMessage, - rawResponse: rawResponse, - }); - default: - throw new errors.IntercomError({ - message: "Unknown error", - rawResponse: rawResponse, - }); - } -} diff --git a/src/errors/index.ts b/src/errors/index.ts deleted file mode 100644 index 280a57f9..00000000 --- a/src/errors/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { IntercomError } from "./IntercomError.js"; -export { IntercomTimeoutError } from "./IntercomTimeoutError.js"; diff --git a/src/exports.ts b/src/exports.ts deleted file mode 100644 index 7b70ee14..00000000 --- a/src/exports.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./core/exports.js"; diff --git a/src/index.ts b/src/index.ts index e8fc688d..fec3f739 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,408 @@ -export * as Intercom from "./api/index.js"; -export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; -export { IntercomClient } from "./Client.js"; -export { IntercomEnvironment } from "./environments.js"; -export { IntercomError, IntercomTimeoutError } from "./errors/index.js"; -export * from "./exports.js"; +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Errors from './error'; +import * as Uploads from './uploads'; +import { type Agent } from './_shims/index'; +import * as qs from 'qs'; +import * as Core from './core'; +import * as Pagination from './pagination'; +import * as API from './resources/index'; + +const environments = { + us: 'https://api.intercom.io', + eu: 'https://api.eu.intercom.io', + au: 'https://api.au.intercom.io', +}; +type Environment = keyof typeof environments; + +export interface ClientOptions { + /** + * Defaults to process.env['INTERCOM_ACCESS_TOKEN']. + */ + accessToken?: string | undefined; + + /** + * Specifies the environment to use for the API. + * + * Each environment maps to a different base URL: + * - `us` corresponds to `https://api.intercom.io` + * - `eu` corresponds to `https://api.eu.intercom.io` + * - `au` corresponds to `https://api.au.intercom.io` + */ + environment?: Environment; + + /** + * Override the default base URL for the API, e.g., "https://api.example.com/v2/" + * + * Defaults to process.env['INTERCOM_BASE_URL']. + */ + baseURL?: string | null | undefined; + + /** + * The maximum amount of time (in milliseconds) that the client should wait for a response + * from the server before timing out a single request. + * + * Note that request timeouts are retried by default, so in a worst-case scenario you may wait + * much longer than this timeout before the promise succeeds or fails. + */ + timeout?: number; + + /** + * An HTTP agent used to manage HTTP(S) connections. + * + * If not provided, an agent will be constructed by default in the Node.js environment, + * otherwise no agent is used. + */ + httpAgent?: Agent; + + /** + * Specify a custom `fetch` function implementation. + * + * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is + * defined globally. + */ + fetch?: Core.Fetch | undefined; + + /** + * The maximum number of times that the client will retry a request in case of a + * temporary failure, like a network error or a 5XX error from the server. + * + * @default 2 + */ + maxRetries?: number; + + /** + * Default headers to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * header to `undefined` or `null` in request options. + */ + defaultHeaders?: Core.Headers; + + /** + * Default query parameters to include with every request to the API. + * + * These can be removed in individual requests by explicitly setting the + * param to `undefined` in request options. + */ + defaultQuery?: Core.DefaultQuery; +} + +/** + * API Client for interfacing with the Intercom API. + */ +export class Intercom extends Core.APIClient { + accessToken: string; + + private _options: ClientOptions; + + /** + * API Client for interfacing with the Intercom API. + * + * @param {string | undefined} [opts.accessToken=process.env['INTERCOM_ACCESS_TOKEN'] ?? undefined] + * @param {Environment} [opts.environment=us] - Specifies the environment URL to use for the API. + * @param {string} [opts.baseURL=process.env['INTERCOM_BASE_URL'] ?? https://api.intercom.io] - Override the default base URL for the API. + * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. + * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. + * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. + * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. + * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. + * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. + */ + constructor({ + baseURL = Core.readEnv('INTERCOM_BASE_URL'), + accessToken = Core.readEnv('INTERCOM_ACCESS_TOKEN'), + ...opts + }: ClientOptions = {}) { + if (accessToken === undefined) { + throw new Errors.IntercomError( + "The INTERCOM_ACCESS_TOKEN environment variable is missing or empty; either provide it, or instantiate the Intercom client with an accessToken option, like new Intercom({ accessToken: 'My Access Token' }).", + ); + } + + const options: ClientOptions = { + accessToken, + ...opts, + baseURL, + environment: opts.environment ?? 'us', + }; + + if (baseURL && opts.environment) { + throw new Errors.IntercomError( + 'Ambiguous URL; The `baseURL` option (or INTERCOM_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null', + ); + } + + super({ + baseURL: options.baseURL || environments[options.environment || 'us'], + timeout: options.timeout ?? 60000 /* 1 minute */, + httpAgent: options.httpAgent, + maxRetries: options.maxRetries, + fetch: options.fetch, + }); + + this._options = options; + + this.accessToken = accessToken; + } + + me: API.Me = new API.Me(this); + admins: API.Admins = new API.Admins(this); + articles: API.Articles = new API.Articles(this); + helpCenter: API.HelpCenterResource = new API.HelpCenterResource(this); + companies: API.Companies = new API.Companies(this); + contacts: API.Contacts = new API.Contacts(this); + conversations: API.Conversations = new API.Conversations(this); + dataAttributes: API.DataAttributes = new API.DataAttributes(this); + dataEvents: API.DataEvents = new API.DataEvents(this); + dataExports: API.DataExports = new API.DataExports(this); + export: API.Export = new API.Export(this); + download: API.Download = new API.Download(this); + messages: API.Messages = new API.Messages(this); + news: API.News = new API.News(this); + notes: API.Notes = new API.Notes(this); + segments: API.Segments = new API.Segments(this); + subscriptionTypes: API.SubscriptionTypes = new API.SubscriptionTypes(this); + phoneCallRedirects: API.PhoneCallRedirects = new API.PhoneCallRedirects(this); + tags: API.Tags = new API.Tags(this); + teams: API.Teams = new API.Teams(this); + ticketTypes: API.TicketTypes = new API.TicketTypes(this); + tickets: API.Tickets = new API.Tickets(this); + visitors: API.Visitors = new API.Visitors(this); + + protected override defaultQuery(): Core.DefaultQuery | undefined { + return this._options.defaultQuery; + } + + protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers { + return { + ...super.defaultHeaders(opts), + ...this._options.defaultHeaders, + }; + } + + protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers { + return { Authorization: `Bearer ${this.accessToken}` }; + } + + protected override stringifyQuery(query: Record): string { + return qs.stringify(query, { arrayFormat: 'comma' }); + } + + static Intercom = this; + static DEFAULT_TIMEOUT = 60000; // 1 minute + + static IntercomError = Errors.IntercomError; + static APIError = Errors.APIError; + static APIConnectionError = Errors.APIConnectionError; + static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; + static APIUserAbortError = Errors.APIUserAbortError; + static NotFoundError = Errors.NotFoundError; + static ConflictError = Errors.ConflictError; + static RateLimitError = Errors.RateLimitError; + static BadRequestError = Errors.BadRequestError; + static AuthenticationError = Errors.AuthenticationError; + static InternalServerError = Errors.InternalServerError; + static PermissionDeniedError = Errors.PermissionDeniedError; + static UnprocessableEntityError = Errors.UnprocessableEntityError; + + static toFile = Uploads.toFile; + static fileFromPath = Uploads.fileFromPath; +} + +export const { + IntercomError, + APIError, + APIConnectionError, + APIConnectionTimeoutError, + APIUserAbortError, + NotFoundError, + ConflictError, + RateLimitError, + BadRequestError, + AuthenticationError, + InternalServerError, + PermissionDeniedError, + UnprocessableEntityError, +} = Errors; + +export import toFile = Uploads.toFile; +export import fileFromPath = Uploads.fileFromPath; + +export namespace Intercom { + export import RequestOptions = Core.RequestOptions; + + export import CursorPagination = Pagination.CursorPagination; + export import CursorPaginationParams = Pagination.CursorPaginationParams; + export import CursorPaginationResponse = Pagination.CursorPaginationResponse; + + export import Me = API.Me; + export import AdminWithApp = API.AdminWithApp; + export import MeRetrieveParams = API.MeRetrieveParams; + + export import Admins = API.Admins; + export import AdminList = API.AdminList; + export import AdminRetrieveParams = API.AdminRetrieveParams; + export import AdminListParams = API.AdminListParams; + export import AdminSetAwayParams = API.AdminSetAwayParams; + + export import Articles = API.Articles; + export import Article = API.Article; + export import ArticleList = API.ArticleList; + export import ArticleSearchResponse = API.ArticleSearchResponse; + export import DeletedArticleObject = API.DeletedArticleObject; + export import ArticleCreateParams = API.ArticleCreateParams; + export import ArticleRetrieveParams = API.ArticleRetrieveParams; + export import ArticleUpdateParams = API.ArticleUpdateParams; + export import ArticleListParams = API.ArticleListParams; + export import ArticleRemoveParams = API.ArticleRemoveParams; + export import ArticleSearchParams = API.ArticleSearchParams; + + export import HelpCenterResource = API.HelpCenterResource; + export import HelpCenter = API.HelpCenter; + export import HelpCenterList = API.HelpCenterList; + + export import Companies = API.Companies; + export import CompanyList = API.CompanyList; + export import CompanyScroll = API.CompanyScroll; + export import DeletedCompanyObject = API.DeletedCompanyObject; + export import CompanyCreateParams = API.CompanyCreateParams; + export import CompanyRetrieveParams = API.CompanyRetrieveParams; + export import CompanyUpdateParams = API.CompanyUpdateParams; + export import CompanyListParams = API.CompanyListParams; + export import CompanyDeleteParams = API.CompanyDeleteParams; + export import CompanyRetrieveListParams = API.CompanyRetrieveListParams; + export import CompanyScrollParams = API.CompanyScrollParams; + + export import Contacts = API.Contacts; + export import ContactArchived = API.ContactArchived; + export import ContactDeleted = API.ContactDeleted; + export import ContactList = API.ContactList; + export import ContactUnarchived = API.ContactUnarchived; + export import ContactCreateParams = API.ContactCreateParams; + export import ContactRetrieveParams = API.ContactRetrieveParams; + export import ContactUpdateParams = API.ContactUpdateParams; + export import ContactListParams = API.ContactListParams; + export import ContactDeleteParams = API.ContactDeleteParams; + export import ContactArchiveParams = API.ContactArchiveParams; + export import ContactMergeParams = API.ContactMergeParams; + export import ContactSearchParams = API.ContactSearchParams; + export import ContactUnarchiveParams = API.ContactUnarchiveParams; + + export import Conversations = API.Conversations; + export import ConversationListResponse = API.ConversationListResponse; + export import ConversationSearchResponse = API.ConversationSearchResponse; + export import ConversationListResponsesCursorPagination = API.ConversationListResponsesCursorPagination; + export import ConversationCreateParams = API.ConversationCreateParams; + export import ConversationRetrieveParams = API.ConversationRetrieveParams; + export import ConversationUpdateParams = API.ConversationUpdateParams; + export import ConversationListParams = API.ConversationListParams; + export import ConversationConvertParams = API.ConversationConvertParams; + export import ConversationRedactParams = API.ConversationRedactParams; + export import ConversationSearchParams = API.ConversationSearchParams; + + export import DataAttributes = API.DataAttributes; + export import DataAttribute = API.DataAttribute; + export import DataAttributeList = API.DataAttributeList; + export import DataAttributeCreateParams = API.DataAttributeCreateParams; + export import DataAttributeUpdateParams = API.DataAttributeUpdateParams; + export import DataAttributeListParams = API.DataAttributeListParams; + + export import DataEvents = API.DataEvents; + export import DataEventSummary = API.DataEventSummary; + export import DataEventCreateParams = API.DataEventCreateParams; + export import DataEventListParams = API.DataEventListParams; + export import DataEventSummariesParams = API.DataEventSummariesParams; + + export import DataExports = API.DataExports; + export import DataExport = API.DataExport; + export import DataExportContentDataParams = API.DataExportContentDataParams; + + export import Export = API.Export; + export import ExportCancelParams = API.ExportCancelParams; + + export import Download = API.Download; + + export import Messages = API.Messages; + export import MessageCreateParams = API.MessageCreateParams; + + export import News = API.News; + + export import Notes = API.Notes; + export import NoteRetrieveParams = API.NoteRetrieveParams; + + export import Segments = API.Segments; + export import Segment = API.Segment; + export import SegmentList = API.SegmentList; + export import SegmentRetrieveParams = API.SegmentRetrieveParams; + export import SegmentListParams = API.SegmentListParams; + + export import SubscriptionTypes = API.SubscriptionTypes; + export import SubscriptionTypeListParams = API.SubscriptionTypeListParams; + + export import PhoneCallRedirects = API.PhoneCallRedirects; + export import PhoneSwitch = API.PhoneSwitch; + export import PhoneCallRedirectCreateParams = API.PhoneCallRedirectCreateParams; + + export import Tags = API.Tags; + export import TagRetrieveParams = API.TagRetrieveParams; + export import TagListParams = API.TagListParams; + export import TagDeleteParams = API.TagDeleteParams; + export import TagCreateOrUpdateParams = API.TagCreateOrUpdateParams; + + export import Teams = API.Teams; + export import Team = API.Team; + export import TeamList = API.TeamList; + export import TeamRetrieveParams = API.TeamRetrieveParams; + export import TeamListParams = API.TeamListParams; + + export import TicketTypes = API.TicketTypes; + export import TicketType = API.TicketType; + export import TicketTypeList = API.TicketTypeList; + export import TicketTypeCreateParams = API.TicketTypeCreateParams; + export import TicketTypeRetrieveParams = API.TicketTypeRetrieveParams; + export import TicketTypeUpdateParams = API.TicketTypeUpdateParams; + export import TicketTypeListParams = API.TicketTypeListParams; + + export import Tickets = API.Tickets; + export import TicketList = API.TicketList; + export import TicketReply = API.TicketReply; + export import TicketCreateParams = API.TicketCreateParams; + export import TicketReplyParams = API.TicketReplyParams; + export import TicketRetrieveByIDParams = API.TicketRetrieveByIDParams; + export import TicketSearchParams = API.TicketSearchParams; + export import TicketUpdateByIDParams = API.TicketUpdateByIDParams; + + export import Visitors = API.Visitors; + export import Visitor = API.Visitor; + export import VisitorDeletedObject = API.VisitorDeletedObject; + export import VisitorRetrieveParams = API.VisitorRetrieveParams; + export import VisitorUpdateParams = API.VisitorUpdateParams; + export import VisitorConvertParams = API.VisitorConvertParams; + + export import Admin = API.Admin; + export import ArticleContent = API.ArticleContent; + export import ArticleTranslatedContent = API.ArticleTranslatedContent; + export import Company = API.Company; + export import Contact = API.Contact; + export import ContactReference = API.ContactReference; + export import Conversation = API.Conversation; + export import CursorPages = API.CursorPages; + export import GroupContent = API.GroupContent; + export import GroupTranslatedContent = API.GroupTranslatedContent; + export import Message = API.Message; + export import MultipleFilterSearchRequest = API.MultipleFilterSearchRequest; + export import Note = API.Note; + export import PartAttachment = API.PartAttachment; + export import Reference = API.Reference; + export import SearchRequest = API.SearchRequest; + export import SingleFilterSearchRequest = API.SingleFilterSearchRequest; + export import StartingAfterPaging = API.StartingAfterPaging; + export import SubscriptionTypeList = API.SubscriptionTypeList; + export import Tag = API.Tag; + export import TagList = API.TagList; + export import Ticket = API.Ticket; + export import TicketTypeAttribute = API.TicketTypeAttribute; +} + +export default Intercom; diff --git a/src/lib/.keep b/src/lib/.keep new file mode 100644 index 00000000..7554f8b2 --- /dev/null +++ b/src/lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. diff --git a/src/pagination.ts b/src/pagination.ts new file mode 100644 index 00000000..67e18169 --- /dev/null +++ b/src/pagination.ts @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core'; + +export interface CursorPaginationResponse { + pages: CursorPaginationResponse.Pages; + + total_count: number; + + data: Array; +} + +export namespace CursorPaginationResponse { + export interface Pages { + next?: Pages.Next; + + page?: number; + + total_pages?: number; + + type?: string; + } + + export namespace Pages { + export interface Next { + page?: number; + + starting_after?: string; + } + } +} + +export interface CursorPaginationParams { + /** + * The pagination cursor value. + */ + starting_after?: string; + + /** + * Number of results to return per page. + */ + per_page?: number; +} + +export class CursorPagination extends AbstractPage implements CursorPaginationResponse { + pages: CursorPaginationResponse.Pages; + + total_count: number; + + data: Array; + + constructor( + client: APIClient, + response: Response, + body: CursorPaginationResponse, + options: FinalRequestOptions, + ) { + super(client, response, body, options); + + this.pages = body.pages || {}; + this.total_count = body.total_count || 0; + this.data = body.data || []; + } + + getPaginatedItems(): Item[] { + return this.data ?? []; + } + + // @deprecated Please use `nextPageInfo()` instead + nextPageParams(): Partial | null { + const info = this.nextPageInfo(); + if (!info) return null; + if ('params' in info) return info.params; + const params = Object.fromEntries(info.url.searchParams); + if (!Object.keys(params).length) return null; + return params; + } + + nextPageInfo(): PageInfo | null { + const cursor = this.pages?.next?.starting_after; + if (!cursor) { + return null; + } + + return { + params: { + starting_after: cursor, + }, + }; + } +} diff --git a/src/resource.ts b/src/resource.ts new file mode 100644 index 00000000..152a6026 --- /dev/null +++ b/src/resource.ts @@ -0,0 +1,11 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import type { Intercom } from './index'; + +export class APIResource { + protected _client: Intercom; + + constructor(client: Intercom) { + this._client = client; + } +} diff --git a/src/resources/admins/activity-logs.ts b/src/resources/admins/activity-logs.ts new file mode 100644 index 00000000..00147d81 --- /dev/null +++ b/src/resources/admins/activity-logs.ts @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as ActivityLogsAPI from './activity-logs'; +import * as Shared from '../shared'; + +export class ActivityLogs extends APIResource { + /** + * You can get a log of activities by all admins in an app. + */ + list(params: ActivityLogListParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/admins/activity_logs', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A paginated list of activity logs. + */ +export interface ActivityLogList { + /** + * An array of activity logs + */ + activity_logs?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * String representing the object's type. Always has the value `activity_log.list`. + */ + type?: string; +} + +export namespace ActivityLogList { + /** + * Activities performed by Admins. + */ + export interface ActivityLog { + /** + * The id representing the activity. + */ + id?: string; + + /** + * A sentence or two describing the activity. + */ + activity_description?: string; + + activity_type?: + | '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'; + + /** + * The time the activity was created. + */ + created_at?: number; + + /** + * Additional data provided about Admin activity. + */ + metadata?: ActivityLog.Metadata | null; + + /** + * Details about the Admin involved in the activity. + */ + performed_by?: ActivityLog.PerformedBy; + } + + export namespace ActivityLog { + /** + * Additional data provided about Admin activity. + */ + export interface Metadata { + /** + * Indicates if the status was changed automatically or manually. + */ + auto_changed?: string | null; + + /** + * The away mode status which is set to true when away and false when returned. + */ + away_mode?: boolean | null; + + /** + * The reason the Admin is away. + */ + away_status_reason?: string | null; + + /** + * The unique identifier for the contact which is provided by the Client. + */ + external_id?: string | null; + + /** + * Indicates if conversations should be reassigned while an Admin is away. + */ + reassign_conversations?: boolean | null; + + /** + * The way the admin signed in. + */ + sign_in_method?: string | null; + + /** + * The action that initiated the status change. + */ + source?: string | null; + + /** + * The ID of the Admin who initiated the activity. + */ + update_by?: number | null; + + /** + * The name of the Admin who initiated the activity. + */ + update_by_name?: string | null; + } + + /** + * Details about the Admin involved in the activity. + */ + export interface PerformedBy { + /** + * The id representing the admin. + */ + id?: string; + + /** + * The email of the admin. + */ + email?: string; + + /** + * The IP address of the admin. + */ + ip?: string; + + /** + * String representing the object's type. Always has the value `admin`. + */ + type?: string; + } + } +} + +export interface ActivityLogListParams { + /** + * Query param: The start date that you request data for. It must be formatted as a + * UNIX timestamp. + */ + created_at_after: string; + + /** + * Query param: The end date that you request data for. It must be formatted as a + * UNIX timestamp. + */ + created_at_before?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace ActivityLogs { + export import ActivityLogList = ActivityLogsAPI.ActivityLogList; + export import ActivityLogListParams = ActivityLogsAPI.ActivityLogListParams; +} diff --git a/src/resources/admins/admins.ts b/src/resources/admins/admins.ts new file mode 100644 index 00000000..cc4dac3f --- /dev/null +++ b/src/resources/admins/admins.ts @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as AdminsAPI from './admins'; +import * as Shared from '../shared'; +import * as ActivityLogsAPI from './activity-logs'; + +export class Admins extends APIResource { + activityLogs: ActivityLogsAPI.ActivityLogs = new ActivityLogsAPI.ActivityLogs(this._client); + + /** + * You can retrieve the details of a single admin. + */ + retrieve( + id: number, + params?: AdminRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: AdminRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/admins/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of admins for a given workspace. + */ + list(params?: AdminListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: AdminListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/admins', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can set an Admin as away for the Inbox. + */ + setAway( + id: number, + params: AdminSetAwayParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/admins/${id}/away`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A list of admins associated with a given workspace. + */ +export interface AdminList { + /** + * A list of admins associated with a given workspace. + */ + admins?: Array; + + /** + * String representing the object's type. Always has the value `admin.list`. + */ + type?: string; +} + +export interface AdminRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface AdminListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface AdminSetAwayParams { + /** + * Body param: Set to "true" to change the status of the admin to away. + */ + away_mode_enabled: boolean; + + /** + * Body param: Set to "true" to assign any new conversation replies to your default + * inbox. + */ + away_mode_reassign: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Admins { + export import AdminList = AdminsAPI.AdminList; + export import AdminRetrieveParams = AdminsAPI.AdminRetrieveParams; + export import AdminListParams = AdminsAPI.AdminListParams; + export import AdminSetAwayParams = AdminsAPI.AdminSetAwayParams; + export import ActivityLogs = ActivityLogsAPI.ActivityLogs; + export import ActivityLogList = ActivityLogsAPI.ActivityLogList; + export import ActivityLogListParams = ActivityLogsAPI.ActivityLogListParams; +} diff --git a/src/resources/admins/index.ts b/src/resources/admins/index.ts new file mode 100644 index 00000000..1b0b26ea --- /dev/null +++ b/src/resources/admins/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { ActivityLogList, ActivityLogListParams, ActivityLogs } from './activity-logs'; +export { AdminList, AdminRetrieveParams, AdminListParams, AdminSetAwayParams, Admins } from './admins'; diff --git a/src/resources/articles.ts b/src/resources/articles.ts new file mode 100644 index 00000000..8e72fb33 --- /dev/null +++ b/src/resources/articles.ts @@ -0,0 +1,806 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as ArticlesAPI from './articles'; +import * as Shared from './shared'; + +export class Articles extends APIResource { + /** + * You can create a new article by making a POST request to + * `https://api.intercom.io/articles`. + */ + create(params: ArticleCreateParams, options?: Core.RequestOptions): Core.APIPromise
{ + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/articles', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single article by making a GET request to + * `https://api.intercom.io/articles/`. + */ + retrieve( + id: number, + params?: ArticleRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise
; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise
; + retrieve( + id: number, + params: ArticleRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise
{ + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/articles/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update the details of a single article by making a PUT request to + * `https://api.intercom.io/articles/`. + */ + update(id: number, params?: ArticleUpdateParams, options?: Core.RequestOptions): Core.APIPromise
; + update(id: number, options?: Core.RequestOptions): Core.APIPromise
; + update( + id: number, + params: ArticleUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise
{ + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/articles/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + list(params?: ArticleListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: ArticleListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/articles', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete a single article by making a DELETE request to + * `https://api.intercom.io/articles/`. + */ + remove( + id: number, + params?: ArticleRemoveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + remove(id: number, options?: Core.RequestOptions): Core.APIPromise; + remove( + id: number, + params: ArticleRemoveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.remove(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/articles/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can search for articles by making a GET request to + * `https://api.intercom.io/articles/search`. + */ + search(params?: ArticleSearchParams, options?: Core.RequestOptions): Core.APIPromise; + search(options?: Core.RequestOptions): Core.APIPromise; + search( + params: ArticleSearchParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.search({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/articles/search', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * The data returned about your articles when you list them. + */ +export interface Article { + /** + * The unique identifier for the article which is given by Intercom. + */ + id?: 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; + + /** + * The body of the article in HTML. For multilingual articles, this will be the + * body of the default language's content. + */ + body?: string | null; + + /** + * 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 default locale of the help center. This field is only returned for + * multilingual help centers. + */ + default_locale?: string; + + /** + * The description of the article. For multilingual articles, this will be the + * description of the default language's content. + */ + description?: string | null; + + /** + * The id of the article's parent collection or section. An article without this + * field stands alone. + */ + parent_id?: number | null; + + /** + * The ids of the article's parent collections or sections. An article without this + * field stands alone. + */ + parent_ids?: Array; + + /** + * The type of parent, which can either be a `collection` or `section`. + */ + parent_type?: string | null; + + /** + * Whether the article is `published` or is a `draft`. For multilingual articles, + * this will be the state of the default language's content. + */ + state?: 'published' | 'draft'; + + /** + * The title of the article. For multilingual articles, this will be the title of + * the default language's content. + */ + title?: string; + + /** + * The Translated Content of an Article. The keys are the locale codes and the + * values are the translated content of the article. + */ + translated_content?: Shared.ArticleTranslatedContent | null; + + /** + * The type of object - `article`. + */ + type?: 'article'; + + /** + * 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 | null; + + /** + * The id of the workspace which the article belongs to. + */ + workspace_id?: string; +} + +/** + * This will return a list of articles for the App. + */ +export interface ArticleList { + /** + * An array of Article objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of articles. + */ + total_count?: number; + + /** + * The type of the object - `list`. + */ + type?: 'list'; +} + +export namespace ArticleList { + /** + * The data returned about your articles when you list them. + */ + export interface Data { + /** + * The unique identifier for the article which is given by Intercom. + */ + id?: 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; + + /** + * The body of the article in HTML. For multilingual articles, this will be the + * body of the default language's content. + */ + body?: string | null; + + /** + * 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 default locale of the help center. This field is only returned for + * multilingual help centers. + */ + default_locale?: string; + + /** + * The description of the article. For multilingual articles, this will be the + * description of the default language's content. + */ + description?: string | null; + + /** + * The id of the article's parent collection or section. An article without this + * field stands alone. + */ + parent_id?: number | null; + + /** + * The ids of the article's parent collections or sections. An article without this + * field stands alone. + */ + parent_ids?: Array; + + /** + * The type of parent, which can either be a `collection` or `section`. + */ + parent_type?: string | null; + + /** + * Whether the article is `published` or is a `draft`. For multilingual articles, + * this will be the state of the default language's content. + */ + state?: 'published' | 'draft'; + + /** + * The title of the article. For multilingual articles, this will be the title of + * the default language's content. + */ + title?: string; + + /** + * The Translated Content of an Article. The keys are the locale codes and the + * values are the translated content of the article. + */ + translated_content?: Shared.ArticleTranslatedContent | null; + + /** + * The type of object - `article`. + */ + type?: 'article'; + + /** + * 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 | null; + + /** + * The id of the workspace which the article belongs to. + */ + workspace_id?: string; + } +} + +/** + * The results of an Article search + */ +export interface ArticleSearchResponse { + /** + * An object containing the results of the search. + */ + data?: ArticleSearchResponse.Data; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * The total number of Articles matching the search query + */ + total_count?: number; + + /** + * The type of the object - `list`. + */ + type?: 'list'; +} + +export namespace ArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** + * An array of Article objects + */ + articles?: Array; + + /** + * A corresponding array of highlighted Article content + */ + highlights?: Array; + } + + export namespace Data { + /** + * The highlighted results of an Article search. In the examples provided my search + * query is always "my query". + */ + export interface Highlight { + /** + * The ID of the corresponding article. + */ + article_id?: string; + + /** + * An Article description and body text highlighted. + */ + highlighted_summary?: Array>; + + /** + * An Article title highlighted. + */ + highlighted_title?: Array; + } + + export namespace Highlight { + /** + * An instance of highlighted summary text. + */ + export interface HighlightedSummary { + /** + * The text of the title. + */ + text?: string; + + /** + * The type of text - `highlight` or `plain`. + */ + type?: 'highlight' | 'plain'; + } + + /** + * A highlighted article title. + */ + export interface HighlightedTitle { + /** + * The text of the title. + */ + text?: string; + + /** + * The type of text - `highlight` or `plain`. + */ + type?: 'highlight' | 'plain'; + } + } + } +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedArticleObject { + /** + * The unique identifier for the article which you provided in the URL. + */ + id?: string; + + /** + * Whether the article was deleted successfully or not. + */ + deleted?: boolean; + + /** + * The type of object which was deleted. - article + */ + object?: 'article'; +} + +export interface ArticleCreateParams { + /** + * Body param: 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; + + /** + * Body param: The title of the article.For multilingual articles, this will be the + * title of the default language's content. + */ + title: string; + + /** + * Body param: The content of the article. For multilingual articles, this will be + * the body of the default language's content. + */ + body?: string; + + /** + * Body param: The description of the article. For multilingual articles, this will + * be the description of the default language's content. + */ + description?: string; + + /** + * Body param: The id of the article's parent collection or section. An article + * without this field stands alone. + */ + parent_id?: number; + + /** + * Body param: The type of parent, which can either be a `collection` or `section`. + */ + parent_type?: string; + + /** + * Body param: 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?: 'published' | 'draft'; + + /** + * Body param: The Translated Content of an Article. The keys are the locale codes + * and the values are the translated content of the article. + */ + translated_content?: Shared.ArticleTranslatedContent | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ArticleRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ArticleUpdateParams { + /** + * Body param: 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; + + /** + * Body param: The content of the article. For multilingual articles, this will be + * the body of the default language's content. + */ + body?: string; + + /** + * Body param: The description of the article. For multilingual articles, this will + * be the description of the default language's content. + */ + description?: string; + + /** + * Body param: The id of the article's parent collection or section. An article + * without this field stands alone. + */ + parent_id?: string; + + /** + * Body param: The type of parent, which can either be a `collection` or `section`. + */ + parent_type?: string; + + /** + * Body param: 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?: 'published' | 'draft'; + + /** + * Body param: The title of the article.For multilingual articles, this will be the + * title of the default language's content. + */ + title?: string; + + /** + * Body param: The Translated Content of an Article. The keys are the locale codes + * and the values are the translated content of the article. + */ + translated_content?: Shared.ArticleTranslatedContent | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ArticleListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ArticleRemoveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ArticleSearchParams { + /** + * Query param: The ID of the Help Center to search in. + */ + help_center_id?: number; + + /** + * Query param: Return a highlighted version of the matching content within your + * articles. Refer to the response schema for more details. + */ + highlight?: boolean; + + /** + * Query param: The phrase within your articles to search for. + */ + phrase?: string; + + /** + * Query param: The state of the Articles returned. One of `published`, `draft` or + * `all`. + */ + state?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Articles { + export import Article = ArticlesAPI.Article; + export import ArticleList = ArticlesAPI.ArticleList; + export import ArticleSearchResponse = ArticlesAPI.ArticleSearchResponse; + export import DeletedArticleObject = ArticlesAPI.DeletedArticleObject; + export import ArticleCreateParams = ArticlesAPI.ArticleCreateParams; + export import ArticleRetrieveParams = ArticlesAPI.ArticleRetrieveParams; + export import ArticleUpdateParams = ArticlesAPI.ArticleUpdateParams; + export import ArticleListParams = ArticlesAPI.ArticleListParams; + export import ArticleRemoveParams = ArticlesAPI.ArticleRemoveParams; + export import ArticleSearchParams = ArticlesAPI.ArticleSearchParams; +} diff --git a/src/resources/companies/companies.ts b/src/resources/companies/companies.ts new file mode 100644 index 00000000..64922968 --- /dev/null +++ b/src/resources/companies/companies.ts @@ -0,0 +1,645 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as CompaniesAPI from './companies'; +import * as Shared from '../shared'; +import * as ContactsAPI from './contacts'; +import * as SegmentsAPI from './segments'; + +export class Companies extends APIResource { + contacts: ContactsAPI.Contacts = new ContactsAPI.Contacts(this._client); + segments: SegmentsAPI.Segments = new SegmentsAPI.Segments(this._client); + + /** + * 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="attention" 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 %} + */ + create(params?: CompanyCreateParams, options?: Core.RequestOptions): Core.APIPromise; + create(options?: Core.RequestOptions): Core.APIPromise; + create( + params: CompanyCreateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.create({}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/companies', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a single company. + */ + retrieve( + id: string, + params?: CompanyRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: CompanyRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/companies/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update a single company using the Intercom provisioned `id`. + * + * {% admonition type="attention" 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 %} + */ + update( + id: string, + params?: CompanyUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: string, options?: Core.RequestOptions): Core.APIPromise; + update( + id: string, + params: CompanyUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.put(`/companies/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + list(params?: CompanyListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: CompanyListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { order, page, per_page, 'Intercom-Version': intercomVersion } = params; + return this._client.post('/companies/list', { + query: { order, page, per_page }, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete a single company. + */ + delete( + id: string, + params?: CompanyDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + id: string, + params: CompanyDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/companies/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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}` + */ + retrieveList( + params?: CompanyRetrieveListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieveList(options?: Core.RequestOptions): Core.APIPromise; + retrieveList( + params: CompanyRetrieveListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieveList({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/companies', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + scroll(params?: CompanyScrollParams, options?: Core.RequestOptions): Core.APIPromise; + scroll(options?: Core.RequestOptions): Core.APIPromise; + scroll( + params: CompanyScrollParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.scroll({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/companies/scroll', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * This will return a list of companies for the App. + */ +export interface CompanyList { + /** + * An array containing Company Objects. + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * The total number of companies. + */ + total_count?: number; + + /** + * The type of object - `list`. + */ + type?: 'list'; +} + +/** + * 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 { + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * The scroll parameter to use in the next request to fetch the next page of + * results. + */ + scroll_param?: string; + + /** + * The total number of companies + */ + total_count?: number | null; + + /** + * The type of object - `list` + */ + type?: 'list'; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCompanyObject { + /** + * The unique identifier for the company which is given by Intercom. + */ + id?: string; + + /** + * Whether the company was deleted successfully or not. + */ + deleted?: boolean; + + /** + * The type of object which was deleted. - `company` + */ + object?: 'company'; +} + +export interface CompanyCreateParams { + /** + * Body param: The company id you have defined for the company. Can't be updated + */ + company_id?: string; + + /** + * Body param: A hash of key/value pairs containing any other data about the + * company you want Intercom to store. + */ + custom_attributes?: Record; + + /** + * Body param: The industry that this company operates in. + */ + industry?: string; + + /** + * Body param: How much revenue the company generates for your business. Note that + * this will truncate floats. i.e. it only allow for whole integers, 155.98 will be + * truncated to 155. Note that this has an upper limit of 2\*\*31-1 or 2147483647.. + */ + monthly_spend?: number; + + /** + * Body param: The name of the Company + */ + name?: string; + + /** + * Body param: The name of the plan you have associated with the company. + */ + plan?: string; + + /** + * Body param: The time the company was created by you. + */ + remote_created_at?: number; + + /** + * Body param: The number of employees in this company. + */ + size?: number; + + /** + * Body param: The URL for this company's website. Please note that the value + * specified here is not validated. Accepts any string. + */ + website?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CompanyRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CompanyUpdateParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CompanyListParams { + /** + * Query param: `asc` or `desc`. Return the companies in ascending or descending + * order. Defaults to desc + */ + order?: string; + + /** + * Query param: The page of results to fetch. Defaults to first page + */ + page?: number; + + /** + * Query param: How many results to return per page. Defaults to 15 + */ + per_page?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CompanyDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CompanyRetrieveListParams { + /** + * Query param: The `company_id` of the company to filter by. + */ + company_id?: string; + + /** + * Query param: The `name` of the company to filter by. + */ + name?: string; + + /** + * Query param: The page of results to fetch. Defaults to first page + */ + page?: number; + + /** + * Query param: How many results to display per page. Defaults to 15 + */ + per_page?: number; + + /** + * Query param: The `segment_id` of the company to filter by. + */ + segment_id?: string; + + /** + * Query param: The `tag_id` of the company to filter by. + */ + tag_id?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CompanyScrollParams { + /** + * Query param: + */ + scroll_param?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Companies { + export import CompanyList = CompaniesAPI.CompanyList; + export import CompanyScroll = CompaniesAPI.CompanyScroll; + export import DeletedCompanyObject = CompaniesAPI.DeletedCompanyObject; + export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams; + export import CompanyRetrieveParams = CompaniesAPI.CompanyRetrieveParams; + export import CompanyUpdateParams = CompaniesAPI.CompanyUpdateParams; + export import CompanyListParams = CompaniesAPI.CompanyListParams; + export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams; + export import CompanyRetrieveListParams = CompaniesAPI.CompanyRetrieveListParams; + export import CompanyScrollParams = CompaniesAPI.CompanyScrollParams; + export import Contacts = ContactsAPI.Contacts; + export import CompanyAttachedContacts = ContactsAPI.CompanyAttachedContacts; + export import ContactListParams = ContactsAPI.ContactListParams; + export import Segments = SegmentsAPI.Segments; + export import CompanyAttachedSegments = SegmentsAPI.CompanyAttachedSegments; + export import SegmentListParams = SegmentsAPI.SegmentListParams; +} diff --git a/src/resources/companies/contacts.ts b/src/resources/companies/contacts.ts new file mode 100644 index 00000000..686714c5 --- /dev/null +++ b/src/resources/companies/contacts.ts @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as ContactsAPI from './contacts'; +import * as Shared from '../shared'; + +export class Contacts extends APIResource { + /** + * You can fetch a list of all contacts that belong to a company. + */ + list( + id: string, + params?: ContactListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(id: string, options?: Core.RequestOptions): Core.APIPromise; + list( + id: string, + params: ContactListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/companies/${id}/contacts`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A list of Contact Objects + */ +export interface CompanyAttachedContacts { + /** + * An array containing Contact Objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * The total number of contacts + */ + total_count?: number; + + /** + * The type of object - `list` + */ + type?: 'list'; +} + +export interface ContactListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Contacts { + export import CompanyAttachedContacts = ContactsAPI.CompanyAttachedContacts; + export import ContactListParams = ContactsAPI.ContactListParams; +} diff --git a/src/resources/companies/index.ts b/src/resources/companies/index.ts new file mode 100644 index 00000000..99c3af0f --- /dev/null +++ b/src/resources/companies/index.ts @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { CompanyAttachedContacts, ContactListParams, Contacts } from './contacts'; +export { CompanyAttachedSegments, SegmentListParams, Segments } from './segments'; +export { + CompanyList, + CompanyScroll, + DeletedCompanyObject, + CompanyCreateParams, + CompanyRetrieveParams, + CompanyUpdateParams, + CompanyListParams, + CompanyDeleteParams, + CompanyRetrieveListParams, + CompanyScrollParams, + Companies, +} from './companies'; diff --git a/src/resources/companies/segments.ts b/src/resources/companies/segments.ts new file mode 100644 index 00000000..694238a5 --- /dev/null +++ b/src/resources/companies/segments.ts @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as CompaniesSegmentsAPI from './segments'; +import * as SegmentsAPI from '../segments'; + +export class Segments extends APIResource { + /** + * You can fetch a list of all segments that belong to a company. + */ + list( + id: string, + params?: SegmentListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(id: string, options?: Core.RequestOptions): Core.APIPromise; + list( + id: string, + params: SegmentListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/companies/${id}/segments`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A list of Segment Objects + */ +export interface CompanyAttachedSegments { + /** + * An array containing Segment Objects + */ + data?: Array; + + /** + * The type of object - `list` + */ + type?: 'list'; +} + +export interface SegmentListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Segments { + export import CompanyAttachedSegments = CompaniesSegmentsAPI.CompanyAttachedSegments; + export import SegmentListParams = CompaniesSegmentsAPI.SegmentListParams; +} diff --git a/src/resources/contacts/companies.ts b/src/resources/contacts/companies.ts new file mode 100644 index 00000000..53b859ee --- /dev/null +++ b/src/resources/contacts/companies.ts @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as CompaniesAPI from './companies'; +import * as Shared from '../shared'; + +export class Companies extends APIResource { + /** + * You can attach a company to a single contact. + */ + create( + contactId: string, + params: CompanyCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { company_id, 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/contacts/${contactId}/companies`, { + body: { id: company_id, ...body }, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of companies that are associated to a contact. + */ + list( + contactId: string, + params?: CompanyListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(contactId: string, options?: Core.RequestOptions): Core.APIPromise; + list( + contactId: string, + params: CompanyListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(contactId, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${contactId}/companies`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can detach a company from a single contact. + */ + delete( + contactId: string, + id: string, + params?: CompanyDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(contactId: string, id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + contactId: string, + id: string, + params: CompanyDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(contactId, id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/contacts/${contactId}/companies/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A list of Company Objects + */ +export interface ContactAttachedCompanies { + /** + * An array containing Company Objects + */ + companies?: Array; + + /** + * 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. + */ + pages?: ContactAttachedCompanies.Pages; + + /** + * The total number of companies associated to this contact + */ + total_count?: number; + + /** + * The type of object + */ + type?: 'list'; +} + +export namespace ContactAttachedCompanies { + /** + * 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 Pages { + /** + * 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 | null; + + page?: number; + + per_page?: number; + + total_pages?: number; + + type?: 'pages'; + } +} + +export interface CompanyCreateParams { + /** + * Body param: The unique identifier for the company which is given by Intercom + */ + company_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CompanyListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CompanyDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Companies { + export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies; + export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams; + export import CompanyListParams = CompaniesAPI.CompanyListParams; + export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams; +} diff --git a/src/resources/contacts/contacts.ts b/src/resources/contacts/contacts.ts new file mode 100644 index 00000000..1adbb695 --- /dev/null +++ b/src/resources/contacts/contacts.ts @@ -0,0 +1,904 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as ContactsAPI from './contacts'; +import * as Shared from '../shared'; +import * as CompaniesAPI from './companies'; +import * as NotesAPI from './notes'; +import * as SegmentsAPI from './segments'; +import * as SubscriptionsAPI from './subscriptions'; +import * as TagsAPI from './tags'; + +export class Contacts extends APIResource { + companies: CompaniesAPI.Companies = new CompaniesAPI.Companies(this._client); + notes: NotesAPI.Notes = new NotesAPI.Notes(this._client); + segments: SegmentsAPI.Segments = new SegmentsAPI.Segments(this._client); + subscriptions: SubscriptionsAPI.Subscriptions = new SubscriptionsAPI.Subscriptions(this._client); + tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); + + /** + * You can create a new contact (ie. user or lead). + */ + create(params: ContactCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { body, 'Intercom-Version': intercomVersion } = params; + return this._client.post('/contacts', { + body: body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single contact. + */ + retrieve( + id: string, + params?: ContactRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: ContactRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update an existing contact (ie. user or lead). + */ + update( + id: string, + params?: ContactUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: string, options?: Core.RequestOptions): Core.APIPromise; + update( + id: string, + params: ContactUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/contacts/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + list(params?: ContactListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: ContactListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/contacts', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete a single contact. + */ + delete( + id: string, + params?: ContactDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + id: string, + params: ContactDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/contacts/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can archive a single contact. + */ + archive( + id: string, + params?: ContactArchiveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + archive(id: string, options?: Core.RequestOptions): Core.APIPromise; + archive( + id: string, + params: ContactArchiveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.archive(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.post(`/contacts/${id}/archive`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can merge a contact with a `role` of `lead` into a contact with a `role` of + * `user`. + */ + merge(params?: ContactMergeParams, options?: Core.RequestOptions): Core.APIPromise; + merge(options?: Core.RequestOptions): Core.APIPromise; + merge( + params: ContactMergeParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.merge({}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/contacts/merge', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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="attention" 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 | + */ + search(params: ContactSearchParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/contacts/search', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can unarchive a single contact. + */ + unarchive( + id: string, + params?: ContactUnarchiveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + unarchive(id: string, options?: Core.RequestOptions): Core.APIPromise; + unarchive( + id: string, + params: ContactUnarchiveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.unarchive(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.post(`/contacts/${id}/unarchive`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * archived contact object + */ +export interface ContactArchived { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * Whether the contact is archived or not. + */ + archived?: boolean; + + /** + * The unique identifier for the contact which is provided by the Client. + */ + external_id?: string | null; + + /** + * always contact + */ + type?: 'contact'; +} + +/** + * deleted contact object + */ +export interface ContactDeleted { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * Whether the contact is deleted or not. + */ + deleted?: boolean; + + /** + * The unique identifier for the contact which is provided by the Client. + */ + external_id?: string | null; + + /** + * always contact + */ + type?: 'contact'; +} + +/** + * Contacts are your users in Intercom. + */ +export interface ContactList { + /** + * The list of contact objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * Always list + */ + type?: 'list'; +} + +/** + * unarchived contact object + */ +export interface ContactUnarchived { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * Whether the contact is archived or not. + */ + archived?: boolean; + + /** + * The unique identifier for the contact which is provided by the Client. + */ + external_id?: string | null; + + /** + * always contact + */ + type?: 'contact'; +} + +export type ContactCreateParams = + | ContactCreateParams.CreateContactWithEmail + | ContactCreateParams.CreateContactWithExternalID + | ContactCreateParams.CreateContactWithRole; + +export namespace ContactCreateParams { + export interface CreateContactWithEmail { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CreateContactWithExternalID { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CreateContactWithRole { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ContactUpdateParams { + /** + * Body param: An image URL containing the avatar of a contact + */ + avatar?: string | null; + + /** + * Body param: The custom attributes which are set for the contact + */ + custom_attributes?: unknown | null; + + /** + * Body param: The contacts email + */ + email?: string; + + /** + * Body param: A unique identifier for the contact which is given to Intercom + */ + external_id?: string; + + /** + * Body param: The time when the contact was last seen (either where the Intercom + * Messenger was installed or when specified manually) + */ + last_seen_at?: number | null; + + /** + * Body param: The contacts name + */ + name?: string | null; + + /** + * Body param: The id of an admin that has been assigned account ownership of the + * contact + */ + owner_id?: number | null; + + /** + * Body param: The contacts phone + */ + phone?: string | null; + + /** + * Body param: The role of the contact. + */ + role?: string; + + /** + * Body param: The time specified for when a contact signed up + */ + signed_up_at?: number | null; + + /** + * Body param: Whether the contact is unsubscribed from emails + */ + unsubscribed_from_emails?: boolean | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ContactDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ContactArchiveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface ContactMergeParams { + /** + * Body param: The unique identifier for the contact to merge away from. Must be a + * lead. + */ + from?: string; + + /** + * Body param: The unique identifier for the contact to merge into. Must be a user. + */ + into?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactSearchParams { + /** + * Body param: Search using Intercoms Search APIs with a single filter. + */ + query: Shared.SingleFilterSearchRequest | Shared.MultipleFilterSearchRequest; + + /** + * Body param: + */ + pagination?: Shared.StartingAfterPaging | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactUnarchiveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Contacts { + export import ContactArchived = ContactsAPI.ContactArchived; + export import ContactDeleted = ContactsAPI.ContactDeleted; + export import ContactList = ContactsAPI.ContactList; + export import ContactUnarchived = ContactsAPI.ContactUnarchived; + export import ContactCreateParams = ContactsAPI.ContactCreateParams; + export import ContactRetrieveParams = ContactsAPI.ContactRetrieveParams; + export import ContactUpdateParams = ContactsAPI.ContactUpdateParams; + export import ContactListParams = ContactsAPI.ContactListParams; + export import ContactDeleteParams = ContactsAPI.ContactDeleteParams; + export import ContactArchiveParams = ContactsAPI.ContactArchiveParams; + export import ContactMergeParams = ContactsAPI.ContactMergeParams; + export import ContactSearchParams = ContactsAPI.ContactSearchParams; + export import ContactUnarchiveParams = ContactsAPI.ContactUnarchiveParams; + export import Companies = CompaniesAPI.Companies; + export import ContactAttachedCompanies = CompaniesAPI.ContactAttachedCompanies; + export import CompanyCreateParams = CompaniesAPI.CompanyCreateParams; + export import CompanyListParams = CompaniesAPI.CompanyListParams; + export import CompanyDeleteParams = CompaniesAPI.CompanyDeleteParams; + export import Notes = NotesAPI.Notes; + export import NoteList = NotesAPI.NoteList; + export import NoteCreateParams = NotesAPI.NoteCreateParams; + export import NoteListParams = NotesAPI.NoteListParams; + export import Segments = SegmentsAPI.Segments; + export import ContactSegments = SegmentsAPI.ContactSegments; + export import SegmentListParams = SegmentsAPI.SegmentListParams; + export import Subscriptions = SubscriptionsAPI.Subscriptions; + export import SubscriptionType = SubscriptionsAPI.SubscriptionType; + export import SubscriptionCreateParams = SubscriptionsAPI.SubscriptionCreateParams; + export import SubscriptionListParams = SubscriptionsAPI.SubscriptionListParams; + export import SubscriptionDeleteParams = SubscriptionsAPI.SubscriptionDeleteParams; + export import Tags = TagsAPI.Tags; + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagListParams = TagsAPI.TagListParams; + export import TagDeleteParams = TagsAPI.TagDeleteParams; +} diff --git a/src/resources/contacts/index.ts b/src/resources/contacts/index.ts new file mode 100644 index 00000000..a0d1b301 --- /dev/null +++ b/src/resources/contacts/index.ts @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + ContactArchived, + ContactDeleted, + ContactList, + ContactUnarchived, + ContactCreateParams, + ContactRetrieveParams, + ContactUpdateParams, + ContactListParams, + ContactDeleteParams, + ContactArchiveParams, + ContactMergeParams, + ContactSearchParams, + ContactUnarchiveParams, + Contacts, +} from './contacts'; +export { + ContactAttachedCompanies, + CompanyCreateParams, + CompanyListParams, + CompanyDeleteParams, + Companies, +} from './companies'; +export { ContactSegments, SegmentListParams, Segments } from './segments'; +export { NoteList, NoteCreateParams, NoteListParams, Notes } from './notes'; +export { + SubscriptionType, + SubscriptionCreateParams, + SubscriptionListParams, + SubscriptionDeleteParams, + Subscriptions, +} from './subscriptions'; +export { TagCreateParams, TagListParams, TagDeleteParams, Tags } from './tags'; diff --git a/src/resources/contacts/notes.ts b/src/resources/contacts/notes.ts new file mode 100644 index 00000000..6a908ff2 --- /dev/null +++ b/src/resources/contacts/notes.ts @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as NotesAPI from './notes'; +import * as Shared from '../shared'; + +export class Notes extends APIResource { + /** + * You can add a note to a single contact. + */ + create(id: number, params: NoteCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/contacts/${id}/notes`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of notes that are associated to a contact. + */ + list(id: number, params?: NoteListParams, options?: Core.RequestOptions): Core.APIPromise; + list(id: number, options?: Core.RequestOptions): Core.APIPromise; + list( + id: number, + params: NoteListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${id}/notes`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A paginated list of notes associated with a contact. + */ +export interface NoteList { + /** + * An array of notes. + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of notes. + */ + total_count?: number; + + /** + * String representing the object's type. Always has the value `list`. + */ + type?: string; +} + +export interface NoteCreateParams { + /** + * Body param: The text of the note. + */ + body: string; + + /** + * Body param: The unique identifier of a given admin. + */ + admin_id?: string; + + /** + * Body param: The unique identifier of a given contact. + */ + contact_id?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface NoteListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Notes { + export import NoteList = NotesAPI.NoteList; + export import NoteCreateParams = NotesAPI.NoteCreateParams; + export import NoteListParams = NotesAPI.NoteListParams; +} diff --git a/src/resources/contacts/segments.ts b/src/resources/contacts/segments.ts new file mode 100644 index 00000000..ddf2ad15 --- /dev/null +++ b/src/resources/contacts/segments.ts @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as ContactsSegmentsAPI from './segments'; +import * as SegmentsAPI from '../segments'; + +export class Segments extends APIResource { + /** + * You can fetch a list of segments that are associated to a contact. + */ + list( + contactId: string, + params?: SegmentListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(contactId: string, options?: Core.RequestOptions): Core.APIPromise; + list( + contactId: string, + params: SegmentListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(contactId, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${contactId}/segments`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A list of segments objects attached to a specific contact. + */ +export interface ContactSegments { + /** + * Segment objects associated with the contact. + */ + data?: Array; + + /** + * The type of the object + */ + type?: 'list'; +} + +export interface SegmentListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Segments { + export import ContactSegments = ContactsSegmentsAPI.ContactSegments; + export import SegmentListParams = ContactsSegmentsAPI.SegmentListParams; +} diff --git a/src/resources/contacts/subscriptions.ts b/src/resources/contacts/subscriptions.ts new file mode 100644 index 00000000..b1b9f74c --- /dev/null +++ b/src/resources/contacts/subscriptions.ts @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as SubscriptionsAPI from './subscriptions'; +import * as Shared from '../shared'; + +export class Subscriptions extends APIResource { + /** + * 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. + */ + create( + contactId: string, + params: SubscriptionCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/contacts/${contactId}/subscriptions`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + list( + contactId: string, + params?: SubscriptionListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(contactId: string, options?: Core.RequestOptions): Core.APIPromise; + list( + contactId: string, + params: SubscriptionListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(contactId, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${contactId}/subscriptions`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + delete( + contactId: string, + id: string, + params?: SubscriptionDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(contactId: string, id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + contactId: string, + id: string, + params: SubscriptionDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(contactId, id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/contacts/${contactId}/subscriptions/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A subscription type lets customers easily opt out of non-essential + * communications without missing what's important to them. + */ +export interface SubscriptionType { + /** + * The unique identifier representing the subscription type. + */ + id?: string; + + /** + * Describes the type of consent. + */ + consent_type?: 'opt_out' | 'opt_in'; + + /** + * The message types that this subscription supports - can contain `email` or + * `sms_message`. + */ + content_types?: Array<'email' | 'sms_message'>; + + /** + * A translation object contains the localised details of a subscription type. + */ + default_translation?: SubscriptionType.DefaultTranslation; + + /** + * The state of the subscription type. + */ + state?: 'live' | 'draft' | 'archived'; + + /** + * An array of translations objects with the localised version of the subscription + * type in each available locale within your translation settings. + */ + translations?: Array; + + /** + * The type of the object - subscription + */ + type?: string; +} + +export namespace SubscriptionType { + /** + * A translation object contains the localised details of a subscription type. + */ + export interface DefaultTranslation { + /** + * The localised description of the subscription type. + */ + description?: string; + + /** + * The two character identifier for the language of the translation object. + */ + locale?: string; + + /** + * The localised name of the subscription type. + */ + name?: string; + } + + /** + * A translation object contains the localised details of a subscription type. + */ + export interface Translation { + /** + * The localised description of the subscription type. + */ + description?: string; + + /** + * The two character identifier for the language of the translation object. + */ + locale?: string; + + /** + * The localised name of the subscription type. + */ + name?: string; + } +} + +export interface SubscriptionCreateParams { + /** + * Body param: The unique identifier for the subscription which is given by + * Intercom + */ + id: string; + + /** + * Body param: The consent_type of a subscription, opt_out or opt_in. + */ + consent_type: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface SubscriptionListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface SubscriptionDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Subscriptions { + export import SubscriptionType = SubscriptionsAPI.SubscriptionType; + export import SubscriptionCreateParams = SubscriptionsAPI.SubscriptionCreateParams; + export import SubscriptionListParams = SubscriptionsAPI.SubscriptionListParams; + export import SubscriptionDeleteParams = SubscriptionsAPI.SubscriptionDeleteParams; +} diff --git a/src/resources/contacts/tags.ts b/src/resources/contacts/tags.ts new file mode 100644 index 00000000..118227f1 --- /dev/null +++ b/src/resources/contacts/tags.ts @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as TagsAPI from './tags'; +import * as Shared from '../shared'; + +export class Tags extends APIResource { + /** + * You can tag a specific contact. This will return a tag object for the tag that + * was added to the contact. + */ + create( + contactId: string, + params: TagCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/contacts/${contactId}/tags`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + */ + list( + contactId: string, + params?: TagListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(contactId: string, options?: Core.RequestOptions): Core.APIPromise; + list( + contactId: string, + params: TagListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(contactId, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/contacts/${contactId}/tags`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can remove tag from a specific contact. This will return a tag object for + * the tag that was removed from the contact. + */ + delete( + contactId: string, + id: string, + params?: TagDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(contactId: string, id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + contactId: string, + id: string, + params: TagDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(contactId, id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/contacts/${contactId}/tags/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface TagCreateParams { + /** + * Body param: The unique identifier for the tag which is given by Intercom + */ + id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TagListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TagDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Tags { + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagListParams = TagsAPI.TagListParams; + export import TagDeleteParams = TagsAPI.TagDeleteParams; +} diff --git a/src/resources/conversations/conversations.ts b/src/resources/conversations/conversations.ts new file mode 100644 index 00000000..7c189a15 --- /dev/null +++ b/src/resources/conversations/conversations.ts @@ -0,0 +1,754 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as ConversationsAPI from './conversations'; +import * as Shared from '../shared'; +import * as CustomersAPI from './customers'; +import * as PartsAPI from './parts'; +import * as ReplyAPI from './reply'; +import * as RunAssignmentRulesAPI from './run-assignment-rules'; +import * as TagsAPI from './tags'; +import * as NewsItemsAPI from '../news/news-items'; +import * as NewsfeedsAPI from '../news/newsfeeds/newsfeeds'; +import { CursorPagination, type CursorPaginationParams } from '../../pagination'; + +export class Conversations extends APIResource { + tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); + reply: ReplyAPI.Reply = new ReplyAPI.Reply(this._client); + parts: PartsAPI.Parts = new PartsAPI.Parts(this._client); + runAssignmentRules: RunAssignmentRulesAPI.RunAssignmentRules = new RunAssignmentRulesAPI.RunAssignmentRules( + this._client, + ); + customers: CustomersAPI.Customers = new CustomersAPI.Customers(this._client); + + /** + * 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. + */ + create(params: ConversationCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/conversations', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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). + */ + retrieve( + id: number, + params?: ConversationRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: ConversationRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get(`/conversations/${id}`, { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + update( + id: number, + params?: ConversationUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: number, options?: Core.RequestOptions): Core.APIPromise; + update( + id: number, + params: ConversationUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { display_as, 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/conversations/${id}`, { + query: { display_as }, + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + list( + params?: ConversationListParams, + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + options?: Core.RequestOptions, + ): Core.PagePromise; + list( + params: ConversationListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.PagePromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.getAPIList('/conversations', ConversationListResponsesCursorPagination, { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can convert a conversation to a ticket. + */ + convert( + id: number, + params: ConversationConvertParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/conversations/${id}/convert`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 %} + */ + redact( + params: ConversationRedactParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/conversations/redact', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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 as part of the The conversation model is searchable, whether + * writeable or not. The value you search for has to match the accepted type, + * otherwise the query will fail (ie. as `created_at` accepts a date, the `value` + * cannot be a string such as `"foorbar"`). + * + * | 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 | + */ + search( + params: ConversationSearchParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/conversations/search', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export class ConversationListResponsesCursorPagination extends CursorPagination {} + +/** + * 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 type ConversationListResponse = NewsItemsAPI.NewsItem | NewsfeedsAPI.Newsfeed; + +/** + * 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 ConversationSearchResponse { + /** + * The list of conversation objects + */ + conversations?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * Always conversation.list + */ + type?: 'conversation.list'; +} + +export interface ConversationCreateParams { + /** + * Body param: The content of the message. HTML is not supported. + */ + body: string; + + /** + * Body param: + */ + from: ConversationCreateParams.From; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace ConversationCreateParams { + export interface From { + /** + * The identifier for the contact which is given by Intercom. + */ + id: string; + + /** + * The role associated to the contact - user or lead. + */ + type: 'lead' | 'user' | 'contact'; + } +} + +export interface ConversationRetrieveParams { + /** + * Query param: Set to plaintext to retrieve conversation messages in plain text. + */ + display_as?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ConversationUpdateParams { + /** + * Query param: Set to plaintext to retrieve conversation messages in plain text. + */ + display_as?: string; + + /** + * Body param: 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. + */ + custom_attributes?: Record; + + /** + * Body param: Mark a conversation as read within Intercom. + */ + read?: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace ConversationUpdateParams { + /** + * 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 custom attributes you have set on the custom object instance. + */ + custom_attributes?: Record; + + /** + * The id you have defined for the custom object instance. + */ + external_id?: string; + + /** + * The identifier of the custom object type that defines the structure of the + * custom object instance. + */ + type?: string; + } +} + +export interface ConversationListParams extends CursorPaginationParams { + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ConversationConvertParams { + /** + * Body param: The ID of the type of ticket you want to convert the conversation to + */ + ticket_type_id: string; + + /** + * Body param: 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`). + */ + attributes?: Record>; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 type ConversationRedactParams = + | ConversationRedactParams.RedactConversationPartRequest + | ConversationRedactParams.RedactConversationSourceRequest; + +export namespace ConversationRedactParams { + export interface RedactConversationPartRequest { + /** + * Body param: The id of the conversation. + */ + conversation_id: string; + + /** + * Body param: The id of the conversation_part. + */ + conversation_part_id: string; + + /** + * Body param: The type of resource being redacted. + */ + type: 'conversation_part'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface RedactConversationSourceRequest { + /** + * Body param: The id of the conversation. + */ + conversation_id: string; + + /** + * Body param: The id of the source. + */ + source_id: string; + + /** + * Body param: The type of resource being redacted. + */ + type: 'source'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ConversationSearchParams { + /** + * Body param: Search using Intercoms Search APIs with a single filter. + */ + query: Shared.SingleFilterSearchRequest | Shared.MultipleFilterSearchRequest; + + /** + * Body param: + */ + pagination?: Shared.StartingAfterPaging | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Conversations { + export import ConversationListResponse = ConversationsAPI.ConversationListResponse; + export import ConversationSearchResponse = ConversationsAPI.ConversationSearchResponse; + export import ConversationListResponsesCursorPagination = ConversationsAPI.ConversationListResponsesCursorPagination; + export import ConversationCreateParams = ConversationsAPI.ConversationCreateParams; + export import ConversationRetrieveParams = ConversationsAPI.ConversationRetrieveParams; + export import ConversationUpdateParams = ConversationsAPI.ConversationUpdateParams; + export import ConversationListParams = ConversationsAPI.ConversationListParams; + export import ConversationConvertParams = ConversationsAPI.ConversationConvertParams; + export import ConversationRedactParams = ConversationsAPI.ConversationRedactParams; + export import ConversationSearchParams = ConversationsAPI.ConversationSearchParams; + export import Tags = TagsAPI.Tags; + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagDeleteParams = TagsAPI.TagDeleteParams; + export import Reply = ReplyAPI.Reply; + export import ReplyCreateParams = ReplyAPI.ReplyCreateParams; + export import Parts = PartsAPI.Parts; + export import PartCreateParams = PartsAPI.PartCreateParams; + export import RunAssignmentRules = RunAssignmentRulesAPI.RunAssignmentRules; + export import RunAssignmentRuleCreateParams = RunAssignmentRulesAPI.RunAssignmentRuleCreateParams; + export import Customers = CustomersAPI.Customers; + export import CustomerCreateParams = CustomersAPI.CustomerCreateParams; + export import CustomerDeleteParams = CustomersAPI.CustomerDeleteParams; +} diff --git a/src/resources/conversations/customers.ts b/src/resources/conversations/customers.ts new file mode 100644 index 00000000..8429cfca --- /dev/null +++ b/src/resources/conversations/customers.ts @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as CustomersAPI from './customers'; +import * as Shared from '../shared'; + +export class Customers extends APIResource { + /** + * You can add participants who are contacts to a conversation, on behalf of either + * another contact or an admin. + * + * {% admonition type="attention" 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 %} + */ + create( + id: string, + params?: CustomerCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + create(id: string, options?: Core.RequestOptions): Core.APIPromise; + create( + id: string, + params: CustomerCreateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.create(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/conversations/${id}/customers`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either + * another contact or an admin. + * + * {% admonition type="attention" 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 %} + */ + delete( + conversationId: string, + contactId: string, + params: CustomerDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.delete(`/conversations/${conversationId}/customers/${contactId}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface CustomerCreateParams { + /** + * Body param: The `id` of the admin who is adding the new participant. + */ + admin_id?: string; + + /** + * Body param: + */ + customer?: CustomerCreateParams.IntercomUserID | CustomerCreateParams.UserID | CustomerCreateParams.Email; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace CustomerCreateParams { + export interface IntercomUserID { + /** + * The identifier for the contact as given by Intercom. + */ + intercom_user_id: string; + + customer?: IntercomUserID.IntercomUserID | IntercomUserID.UserID | IntercomUserID.Email | null; + } + + export namespace IntercomUserID { + export interface IntercomUserID { + /** + * The identifier for the contact as given by Intercom. + */ + intercom_user_id: string; + } + + export interface UserID { + /** + * The external_id you have defined for the contact who is being added as a + * participant. + */ + user_id: string; + } + + export interface Email { + /** + * The email you have defined for the contact who is being added as a participant. + */ + email: string; + } + } + + export interface UserID { + /** + * The external_id you have defined for the contact who is being added as a + * participant. + */ + user_id: string; + + customer?: UserID.IntercomUserID | UserID.UserID | UserID.Email | null; + } + + export namespace UserID { + export interface IntercomUserID { + /** + * The identifier for the contact as given by Intercom. + */ + intercom_user_id: string; + } + + export interface UserID { + /** + * The external_id you have defined for the contact who is being added as a + * participant. + */ + user_id: string; + } + + export interface Email { + /** + * The email you have defined for the contact who is being added as a participant. + */ + email: string; + } + } + + export interface Email { + /** + * The email you have defined for the contact who is being added as a participant. + */ + email: string; + + customer?: Email.IntercomUserID | Email.UserID | Email.Email | null; + } + + export namespace Email { + export interface IntercomUserID { + /** + * The identifier for the contact as given by Intercom. + */ + intercom_user_id: string; + } + + export interface UserID { + /** + * The external_id you have defined for the contact who is being added as a + * participant. + */ + user_id: string; + } + + export interface Email { + /** + * The email you have defined for the contact who is being added as a participant. + */ + email: string; + } + } +} + +export interface CustomerDeleteParams { + /** + * Body param: The `id` of the admin who is performing the action. + */ + admin_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Customers { + export import CustomerCreateParams = CustomersAPI.CustomerCreateParams; + export import CustomerDeleteParams = CustomersAPI.CustomerDeleteParams; +} diff --git a/src/resources/conversations/index.ts b/src/resources/conversations/index.ts new file mode 100644 index 00000000..c68bbad1 --- /dev/null +++ b/src/resources/conversations/index.ts @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + ConversationListResponse, + ConversationSearchResponse, + ConversationCreateParams, + ConversationRetrieveParams, + ConversationUpdateParams, + ConversationListParams, + ConversationConvertParams, + ConversationRedactParams, + ConversationSearchParams, + ConversationListResponsesCursorPagination, + Conversations, +} from './conversations'; +export { CustomerCreateParams, CustomerDeleteParams, Customers } from './customers'; +export { PartCreateParams, Parts } from './parts'; +export { ReplyCreateParams, Reply } from './reply'; +export { RunAssignmentRuleCreateParams, RunAssignmentRules } from './run-assignment-rules'; +export { TagCreateParams, TagDeleteParams, Tags } from './tags'; diff --git a/src/resources/conversations/parts.ts b/src/resources/conversations/parts.ts new file mode 100644 index 00000000..b3179df8 --- /dev/null +++ b/src/resources/conversations/parts.ts @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as PartsAPI from './parts'; +import * as Shared from '../shared'; + +export class Parts extends APIResource { + /** + * 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. + */ + create( + id: string, + params: PartCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/conversations/${id}/parts`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export type PartCreateParams = + | PartCreateParams.CloseConversationRequest + | PartCreateParams.SnoozeConversationRequest + | PartCreateParams.OpenConversationRequest + | PartCreateParams.AssignConversationRequest; + +export namespace PartCreateParams { + export interface CloseConversationRequest { + /** + * Body param: The id of the admin who is performing the action. + */ + admin_id: string; + + /** + * Body param: + */ + message_type: 'close'; + + /** + * Body param: + */ + type: 'admin'; + + /** + * Body param: Optionally you can leave a message in the conversation to provide + * additional context to the user and other teammates. + */ + body?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface SnoozeConversationRequest { + /** + * Body param: The id of the admin who is performing the action. + */ + admin_id: string; + + /** + * Body param: + */ + message_type: 'snoozed'; + + /** + * Body param: The time you want the conversation to reopen. + */ + snoozed_until: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface OpenConversationRequest { + /** + * Body param: The id of the admin who is performing the action. + */ + admin_id: string; + + /** + * Body param: + */ + message_type: 'open'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface AssignConversationRequest { + /** + * Body param: The id of the admin who is performing the action. + */ + admin_id: string; + + /** + * Body param: 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; + + /** + * Body param: + */ + message_type: 'assignment'; + + /** + * Body param: + */ + type: 'admin' | 'team'; + + /** + * Body param: Optionally you can send a response in the conversation when it is + * assigned. + */ + body?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Parts { + export import PartCreateParams = PartsAPI.PartCreateParams; +} diff --git a/src/resources/conversations/reply.ts b/src/resources/conversations/reply.ts new file mode 100644 index 00000000..6c43d43a --- /dev/null +++ b/src/resources/conversations/reply.ts @@ -0,0 +1,288 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as ReplyAPI from './reply'; +import * as Shared from '../shared'; + +export class Reply extends APIResource { + /** + * You can reply to a conversation with a message from an admin or on behalf of a + * contact, or with a note for admins. + */ + create( + id: string, + params: ReplyCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/conversations/${id}/reply`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export type ReplyCreateParams = + | ReplyCreateParams.ContactReplyIntercomUserIDRequest + | ReplyCreateParams.ContactReplyEmailRequest + | ReplyCreateParams.ContactReplyUserIDRequest + | ReplyCreateParams.AdminReplyConversationRequest; + +export namespace ReplyCreateParams { + export interface ContactReplyIntercomUserIDRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactReplyEmailRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactReplyUserIDRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface AdminReplyConversationRequest { + /** + * Body param: The id of the admin who is authoring the comment. + */ + admin_id: string; + + /** + * Body param: + */ + message_type: 'comment' | 'note'; + + /** + * Body param: + */ + type: 'admin'; + + /** + * Body param: A list of files that will be added as attachments. You can include + * up to 10 files + */ + attachment_files?: Array; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The text body of the reply. Notes accept some HTML formatting. Must + * be present for comment and note message types. + */ + body?: string; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace AdminReplyConversationRequest { + /** + * Properties of the attachment files in a conversation part + */ + export interface AttachmentFile { + /** + * The content type of the file + */ + content_type?: string; + + /** + * The base64 encoded file data. + */ + data?: string; + + /** + * The name of the file. + */ + name?: string; + } + } +} + +export namespace Reply { + export import ReplyCreateParams = ReplyAPI.ReplyCreateParams; +} diff --git a/src/resources/conversations/run-assignment-rules.ts b/src/resources/conversations/run-assignment-rules.ts new file mode 100644 index 00000000..5dc521c4 --- /dev/null +++ b/src/resources/conversations/run-assignment-rules.ts @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as RunAssignmentRulesAPI from './run-assignment-rules'; +import * as Shared from '../shared'; + +export class RunAssignmentRules extends APIResource { + /** + * You can let a conversation be automatically assigned following assignment rules. + * {% admonition type="attention" name="When using workflows" %} It is not possible + * to use this endpoint with Workflows. {% /admonition %} + */ + create( + id: string, + params?: RunAssignmentRuleCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + create(id: string, options?: Core.RequestOptions): Core.APIPromise; + create( + id: string, + params: RunAssignmentRuleCreateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.create(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.post(`/conversations/${id}/run_assignment_rules`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface RunAssignmentRuleCreateParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace RunAssignmentRules { + export import RunAssignmentRuleCreateParams = RunAssignmentRulesAPI.RunAssignmentRuleCreateParams; +} diff --git a/src/resources/conversations/tags.ts b/src/resources/conversations/tags.ts new file mode 100644 index 00000000..e247914d --- /dev/null +++ b/src/resources/conversations/tags.ts @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as TagsAPI from './tags'; +import * as Shared from '../shared'; + +export class Tags extends APIResource { + /** + * You can tag a specific conversation. This will return a tag object for the tag + * that was added to the conversation. + */ + create( + conversationId: string, + params: TagCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/conversations/${conversationId}/tags`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can remove tag from a specific conversation. This will return a tag object + * for the tag that was removed from the conversation. + */ + delete( + conversationId: string, + id: string, + params: TagDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.delete(`/conversations/${conversationId}/tags/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface TagCreateParams { + /** + * Body param: The unique identifier for the tag which is given by Intercom + */ + id: string; + + /** + * Body param: The unique identifier for the admin which is given by Intercom. + */ + admin_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TagDeleteParams { + /** + * Body param: The unique identifier for the admin which is given by Intercom. + */ + admin_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Tags { + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagDeleteParams = TagsAPI.TagDeleteParams; +} diff --git a/src/resources/data-attributes.ts b/src/resources/data-attributes.ts new file mode 100644 index 00000000..ba942355 --- /dev/null +++ b/src/resources/data-attributes.ts @@ -0,0 +1,347 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as DataAttributesAPI from './data-attributes'; + +export class DataAttributes extends APIResource { + /** + * You can create a data attributes for a `contact` or a `company`. + */ + create(params: DataAttributeCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/data_attributes', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + update( + id: number, + params?: DataAttributeUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: number, options?: Core.RequestOptions): Core.APIPromise; + update( + id: number, + params: DataAttributeUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/data_attributes/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all data attributes belonging to a workspace for + * contacts, companies or conversations. + */ + list(params?: DataAttributeListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: DataAttributeListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/data_attributes', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * 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 { + /** + * The unique identifier for the data attribute which is given by Intercom. Only + * available for custom attributes. + */ + id?: number; + + /** + * Teammate who created the attribute. Only applicable to CDAs + */ + admin_id?: string; + + /** + * Can this attribute be updated through API + */ + api_writable?: 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; + + /** + * Set to true if this is a CDA + */ + custom?: boolean; + + /** + * The data type of the attribute. + */ + data_type?: 'string' | 'integer' | 'float' | 'boolean' | 'date'; + + /** + * Readable description of the attribute. + */ + description?: 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; + + /** + * Can this attribute be updated by the Messenger + */ + messenger_writable?: boolean; + + /** + * Value is `contact` for user/lead attributes and `company` for company + * attributes. + */ + model?: 'contact' | 'company'; + + /** + * Name of the attribute. + */ + name?: string; + + /** + * List of predefined options for attribute value. + */ + options?: Array; + + /** + * Value is `data_attribute`. + */ + type?: 'data_attribute'; + + /** + * Can this attribute be updated in the UI + */ + ui_writable?: boolean; + + /** + * The time the attribute was last updated as a UTC Unix timestamp + */ + updated_at?: number; +} + +/** + * A list of all data attributes belonging to a workspace for contacts, companies + * or conversations. + */ +export interface DataAttributeList { + /** + * A list of data attributes + */ + data?: Array; + + /** + * The type of the object + */ + type?: 'list'; +} + +export interface DataAttributeCreateParams { + /** + * Body param: The type of data stored for this attribute. + */ + data_type: 'string' | 'integer' | 'float' | 'boolean' | 'datetime' | 'date'; + + /** + * Body param: The model that the data attribute belongs to. + */ + model: 'contact' | 'company'; + + /** + * Body param: The name of the data attribute. + */ + name: string; + + /** + * Body param: The readable description you see in the UI for the attribute. + */ + description?: string; + + /** + * Body param: Can this attribute be updated by the Messenger + */ + messenger_writable?: boolean; + + /** + * Body param: 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?: Array; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface DataAttributeUpdateParams { + /** + * Body param: Whether the attribute is to be archived or not. + */ + archived?: boolean; + + /** + * Body param: The readable description you see in the UI for the attribute. + */ + description?: string; + + /** + * Body param: Can this attribute be updated by the Messenger + */ + messenger_writable?: boolean; + + /** + * Body param: 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?: Array; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface DataAttributeListParams { + /** + * Query param: Include archived attributes in the list. By default we return only + * non archived data attributes. + */ + include_archived?: boolean; + + /** + * Query param: Specify the data attribute model to return. + */ + model?: 'contact' | 'company' | 'conversation'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace DataAttributes { + export import DataAttribute = DataAttributesAPI.DataAttribute; + export import DataAttributeList = DataAttributesAPI.DataAttributeList; + export import DataAttributeCreateParams = DataAttributesAPI.DataAttributeCreateParams; + export import DataAttributeUpdateParams = DataAttributesAPI.DataAttributeUpdateParams; + export import DataAttributeListParams = DataAttributesAPI.DataAttributeListParams; +} diff --git a/src/resources/data-events.ts b/src/resources/data-events.ts new file mode 100644 index 00000000..f604ffba --- /dev/null +++ b/src/resources/data-events.ts @@ -0,0 +1,454 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as DataEventsAPI from './data-events'; + +export class DataEvents extends APIResource { + /** + * 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. + */ + create(params: DataEventCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { body, 'Intercom-Version': intercomVersion } = params; + return this._client.post('/events', { + body: body, + ...options, + headers: { + Accept: '*/*', + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * > 🚧 + * > + * > 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. + */ + list(params: DataEventListParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/events', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + summaries(params?: DataEventSummariesParams, options?: Core.RequestOptions): Core.APIPromise; + summaries(options?: Core.RequestOptions): Core.APIPromise; + summaries( + params: DataEventSummariesParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.summaries({}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/events/summaries', { + body, + ...options, + headers: { + Accept: '*/*', + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * This will return a summary of data events for the App. + */ +export interface DataEventSummary { + /** + * The email address of the user + */ + email?: string; + + /** + * A summary of data events + */ + events?: Array; + + /** + * The Intercom user ID of the user + */ + intercom_user_id?: string; + + /** + * The type of the object + */ + type?: 'event.summary'; + + /** + * The user ID of the user + */ + user_id?: string; +} + +export namespace DataEventSummary { + /** + * This will return a summary of a data event for the App. + */ + export interface Event { + /** + * The number of times the event was sent + */ + count?: number; + + /** + * The description of the event + */ + description?: string; + + /** + * The first time the event was sent + */ + first?: string; + + /** + * The last time the event was sent + */ + last?: string; + + /** + * The name of the event + */ + name?: string; + } +} + +export type DataEventCreateParams = + | DataEventCreateParams.IDRequired + | DataEventCreateParams.UserIDRequired + | DataEventCreateParams.EmailRequired; + +export namespace DataEventCreateParams { + export interface IDRequired { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface UserIDRequired { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface EmailRequired { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface DataEventListParams { + /** + * Query param: + */ + filter: + | DataEventListParams.UserIDQueryParameter + | DataEventListParams.IntercomUserIDQueryParameter + | DataEventListParams.EmailQueryParameter; + + /** + * Query param: The value must be user + */ + type: string; + + /** + * Query param: summary flag + */ + summary?: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace DataEventListParams { + export interface UserIDQueryParameter { + user_id: string; + } + + export interface IntercomUserIDQueryParameter { + intercom_user_id: string; + } + + export interface EmailQueryParameter { + email: string; + } +} + +export interface DataEventSummariesParams { + /** + * Body param: 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?: DataEventSummariesParams.EventSummaries; + + /** + * Body param: Your identifier for the user. + */ + user_id?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace DataEventSummariesParams { + /** + * 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 number of times the event occurred. + */ + count?: number; + + /** + * 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 first time the event was sent + */ + first?: number; + + /** + * The last time the event was sent + */ + last?: number; + } +} + +export namespace DataEvents { + export import DataEventSummary = DataEventsAPI.DataEventSummary; + export import DataEventCreateParams = DataEventsAPI.DataEventCreateParams; + export import DataEventListParams = DataEventsAPI.DataEventListParams; + export import DataEventSummariesParams = DataEventsAPI.DataEventSummariesParams; +} diff --git a/src/resources/data-exports.ts b/src/resources/data-exports.ts new file mode 100644 index 00000000..2c89ba04 --- /dev/null +++ b/src/resources/data-exports.ts @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; +import * as DataExportsAPI from './data-exports'; + +export class DataExports extends APIResource { + /** + * 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. + */ + contentData( + params: DataExportContentDataParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/export/content/data', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * The data export api is used to view all message sent & viewed in a given + * timeframe. + */ +export interface DataExport { + /** + * 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; + + /** + * The identifier for your job. + */ + job_identfier?: string; + + /** + * The current state of your job. + */ + status?: 'pending' | 'in_progress' | 'failed' | 'completed' | 'no_data' | 'canceled'; +} + +export interface DataExportContentDataParams { + /** + * Body param: The start date that you request data for. It must be formatted as a + * unix timestamp. + */ + created_at_after: number; + + /** + * Body param: The end date that you request data for. It must be formatted as a + * unix timestamp. + */ + created_at_before: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace DataExports { + export import DataExport = DataExportsAPI.DataExport; + export import DataExportContentDataParams = DataExportsAPI.DataExportContentDataParams; +} diff --git a/src/resources/download/content/content.ts b/src/resources/download/content/content.ts new file mode 100644 index 00000000..19f75a93 --- /dev/null +++ b/src/resources/download/content/content.ts @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import * as DataAPI from './data'; + +export class Content extends APIResource { + data: DataAPI.Data = new DataAPI.Data(this._client); +} + +export namespace Content { + export import Data = DataAPI.Data; + export import DataRetrieveParams = DataAPI.DataRetrieveParams; +} diff --git a/src/resources/download/content/data.ts b/src/resources/download/content/data.ts new file mode 100644 index 00000000..f707dfc2 --- /dev/null +++ b/src/resources/download/content/data.ts @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; +import * as DataAPI from './data'; + +export class Data extends APIResource { + /** + * 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. + */ + retrieve( + jobIdentifier: string, + params?: DataRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(jobIdentifier: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + jobIdentifier: string, + params: DataRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(jobIdentifier, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/download/content/data/${jobIdentifier}`, { + ...options, + headers: { + Accept: '*/*', + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface DataRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Data { + export import DataRetrieveParams = DataAPI.DataRetrieveParams; +} diff --git a/src/resources/download/content/index.ts b/src/resources/download/content/index.ts new file mode 100644 index 00000000..7526d395 --- /dev/null +++ b/src/resources/download/content/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Content } from './content'; +export { DataRetrieveParams, Data } from './data'; diff --git a/src/resources/download/download.ts b/src/resources/download/download.ts new file mode 100644 index 00000000..5ae40c6e --- /dev/null +++ b/src/resources/download/download.ts @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as ContentAPI from './content/content'; + +export class Download extends APIResource { + content: ContentAPI.Content = new ContentAPI.Content(this._client); +} + +export namespace Download { + export import Content = ContentAPI.Content; +} diff --git a/src/resources/download/index.ts b/src/resources/download/index.ts new file mode 100644 index 00000000..4d4c32f9 --- /dev/null +++ b/src/resources/download/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Content } from './content/index'; +export { Download } from './download'; diff --git a/src/resources/export/content/content.ts b/src/resources/export/content/content.ts new file mode 100644 index 00000000..19f75a93 --- /dev/null +++ b/src/resources/export/content/content.ts @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import * as DataAPI from './data'; + +export class Content extends APIResource { + data: DataAPI.Data = new DataAPI.Data(this._client); +} + +export namespace Content { + export import Data = DataAPI.Data; + export import DataRetrieveParams = DataAPI.DataRetrieveParams; +} diff --git a/src/resources/export/content/data.ts b/src/resources/export/content/data.ts new file mode 100644 index 00000000..20861c05 --- /dev/null +++ b/src/resources/export/content/data.ts @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; +import * as DataAPI from './data'; +import * as DataExportsAPI from '../../data-exports'; + +export class Data extends APIResource { + /** + * 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. + */ + retrieve( + jobIdentifier: string, + params?: DataRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(jobIdentifier: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + jobIdentifier: string, + params: DataRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(jobIdentifier, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/export/content/data/${jobIdentifier}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface DataRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Data { + export import DataRetrieveParams = DataAPI.DataRetrieveParams; +} diff --git a/src/resources/export/content/index.ts b/src/resources/export/content/index.ts new file mode 100644 index 00000000..7526d395 --- /dev/null +++ b/src/resources/export/content/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Content } from './content'; +export { DataRetrieveParams, Data } from './data'; diff --git a/src/resources/export/export.ts b/src/resources/export/export.ts new file mode 100644 index 00000000..5dbc4066 --- /dev/null +++ b/src/resources/export/export.ts @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as ExportAPI from './export'; +import * as DataExportsAPI from '../data-exports'; +import * as ContentAPI from './content/content'; + +export class Export extends APIResource { + content: ContentAPI.Content = new ContentAPI.Content(this._client); + + /** + * You can cancel your job + */ + cancel( + jobIdentifier: string, + params?: ExportCancelParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + cancel(jobIdentifier: string, options?: Core.RequestOptions): Core.APIPromise; + cancel( + jobIdentifier: string, + params: ExportCancelParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.cancel(jobIdentifier, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.post(`/export/cancel/${jobIdentifier}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface ExportCancelParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Export { + export import ExportCancelParams = ExportAPI.ExportCancelParams; + export import Content = ContentAPI.Content; +} diff --git a/src/resources/export/index.ts b/src/resources/export/index.ts new file mode 100644 index 00000000..1a4c1c1f --- /dev/null +++ b/src/resources/export/index.ts @@ -0,0 +1,4 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { Content } from './content/index'; +export { ExportCancelParams, Export } from './export'; diff --git a/src/resources/help-center/collections.ts b/src/resources/help-center/collections.ts new file mode 100644 index 00000000..b5329940 --- /dev/null +++ b/src/resources/help-center/collections.ts @@ -0,0 +1,469 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as CollectionsAPI from './collections'; +import * as Shared from '../shared'; + +export class Collections extends APIResource { + /** + * You can create a new collection by making a POST request to + * `https://api.intercom.io/help_center/collections.` + */ + create(params: CollectionCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/help_center/collections', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single collection by making a GET request to + * `https://api.intercom.io/help_center/collections/`. + */ + retrieve( + id: number, + params?: CollectionRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: CollectionRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/help_center/collections/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update the details of a single collection by making a PUT request to + * `https://api.intercom.io/collections/`. + */ + update( + id: number, + params?: CollectionUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: number, options?: Core.RequestOptions): Core.APIPromise; + update( + id: number, + params: CollectionUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/help_center/collections/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + list(params?: CollectionListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: CollectionListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/help_center/collections', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete a single collection by making a DELETE request to + * `https://api.intercom.io/collections/`. + */ + delete( + id: number, + params?: CollectionDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(id: number, options?: Core.RequestOptions): Core.APIPromise; + delete( + id: number, + params: CollectionDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/help_center/collections/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * 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 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 default locale of the help center. This field is only returned for + * multilingual help centers. + */ + default_locale?: string; + + /** + * The description of the collection. For multilingual help centers, this will be + * the description of the collection for the default language. + */ + description?: string | null; + + /** + * The id of the help center the collection is in. + */ + help_center_id?: number | null; + + /** + * The icon of the collection. + */ + icon?: string | null; + + /** + * The name of the collection. For multilingual collections, this will be the name + * of the default language's content. + */ + name?: 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 id of the parent collection. If `null` then it is the first level + * collection. + */ + parent_id?: string | null; + + /** + * The Translated Content of an Group. The keys are the locale codes and the values + * are the translated content of the Group. + */ + translated_content?: Shared.GroupTranslatedContent | null; + + /** + * 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 | null; + + /** + * The id of the workspace which the collection belongs to. + */ + workspace_id?: string; +} + +/** + * This will return a list of Collections for the App. + */ +export interface CollectionList { + /** + * An array of collection objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of collections. + */ + total_count?: number; + + /** + * The type of the object - `list`. + */ + type?: 'list'; +} + +/** + * Response returned when an object is deleted + */ +export interface DeletedCollection { + /** + * The unique identifier for the collection which you provided in the URL. + */ + id?: string; + + /** + * Whether the collection was deleted successfully or not. + */ + deleted?: boolean; + + /** + * The type of object which was deleted. - `collection` + */ + object?: 'collection'; +} + +export interface CollectionCreateParams { + /** + * Body param: The name of the collection. For multilingual collections, this will + * be the name of the default language's content. + */ + name: string; + + /** + * Body param: The description of the collection. For multilingual collections, + * this will be the description of the default language's content. + */ + description?: string; + + /** + * Body param: 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 | null; + + /** + * Body param: The id of the parent collection. If `null` then it will be created + * as the first level collection. + */ + parent_id?: string | null; + + /** + * Body param: The Translated Content of an Group. The keys are the locale codes + * and the values are the translated content of the Group. + */ + translated_content?: Shared.GroupTranslatedContent | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CollectionRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CollectionUpdateParams { + /** + * Body param: The description of the collection. For multilingual collections, + * this will be the description of the default language's content. + */ + description?: string; + + /** + * Body param: The name of the collection. For multilingual collections, this will + * be the name of the default language's content. + */ + name?: string; + + /** + * Body param: The id of the parent collection. If `null` then it will be updated + * as the first level collection. + */ + parent_id?: string | null; + + /** + * Body param: The Translated Content of an Group. The keys are the locale codes + * and the values are the translated content of the Group. + */ + translated_content?: Shared.GroupTranslatedContent | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface CollectionListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface CollectionDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Collections { + export import Collection = CollectionsAPI.Collection; + export import CollectionList = CollectionsAPI.CollectionList; + export import DeletedCollection = CollectionsAPI.DeletedCollection; + export import CollectionCreateParams = CollectionsAPI.CollectionCreateParams; + export import CollectionRetrieveParams = CollectionsAPI.CollectionRetrieveParams; + export import CollectionUpdateParams = CollectionsAPI.CollectionUpdateParams; + export import CollectionListParams = CollectionsAPI.CollectionListParams; + export import CollectionDeleteParams = CollectionsAPI.CollectionDeleteParams; +} diff --git a/src/resources/help-center/help-center.ts b/src/resources/help-center/help-center.ts new file mode 100644 index 00000000..9f0f851c --- /dev/null +++ b/src/resources/help-center/help-center.ts @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as HelpCenterAPI from './help-center'; +import * as CollectionsAPI from './collections'; +import * as HelpCentersAPI from './help-centers'; + +export class HelpCenterResource extends APIResource { + collections: CollectionsAPI.Collections = new CollectionsAPI.Collections(this._client); + helpCenters: HelpCentersAPI.HelpCenters = new HelpCentersAPI.HelpCenters(this._client); +} + +/** + * Help Centers contain collections + */ +export interface HelpCenter { + /** + * The unique identifier for the Help Center which is given by Intercom. + */ + id?: string; + + /** + * The time when the Help Center was created. + */ + created_at?: number; + + /** + * The display name of the Help Center only seen by teammates. + */ + display_name?: string; + + /** + * The identifier of the Help Center. This is used in the URL of the Help Center. + */ + identifier?: string; + + /** + * The time when the Help Center was last updated. + */ + updated_at?: number; + + /** + * Whether the Help Center is turned on or not. This is controlled in your Help + * Center settings. + */ + website_turned_on?: boolean; + + /** + * The id of the workspace which the Help Center belongs to. + */ + workspace_id?: string; +} + +/** + * A list of Help Centers belonging to the App + */ +export interface HelpCenterList { + /** + * An array of Help Center objects + */ + data?: Array; + + /** + * The type of the object - `list`. + */ + type?: 'list'; +} + +export namespace HelpCenterResource { + export import HelpCenter = HelpCenterAPI.HelpCenter; + export import HelpCenterList = HelpCenterAPI.HelpCenterList; + export import Collections = CollectionsAPI.Collections; + export import Collection = CollectionsAPI.Collection; + export import CollectionList = CollectionsAPI.CollectionList; + export import DeletedCollection = CollectionsAPI.DeletedCollection; + export import CollectionCreateParams = CollectionsAPI.CollectionCreateParams; + export import CollectionRetrieveParams = CollectionsAPI.CollectionRetrieveParams; + export import CollectionUpdateParams = CollectionsAPI.CollectionUpdateParams; + export import CollectionListParams = CollectionsAPI.CollectionListParams; + export import CollectionDeleteParams = CollectionsAPI.CollectionDeleteParams; + export import HelpCenters = HelpCentersAPI.HelpCenters; + export import HelpCenterRetrieveParams = HelpCentersAPI.HelpCenterRetrieveParams; + export import HelpCenterListParams = HelpCentersAPI.HelpCenterListParams; +} diff --git a/src/resources/help-center/help-centers.ts b/src/resources/help-center/help-centers.ts new file mode 100644 index 00000000..4bbedfef --- /dev/null +++ b/src/resources/help-center/help-centers.ts @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as HelpCentersAPI from './help-centers'; +import * as HelpCenterAPI from './help-center'; + +export class HelpCenters extends APIResource { + /** + * You can fetch the details of a single Help Center by making a GET request to + * `https://api.intercom.io/help_center/help_center/`. + */ + retrieve( + id: number, + params?: HelpCenterRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: HelpCenterRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/help_center/help_centers/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can list all Help Centers by making a GET request to + * `https://api.intercom.io/help_center/help_centers`. + */ + list( + params?: HelpCenterListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: HelpCenterListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/help_center/help_centers', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface HelpCenterRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface HelpCenterListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace HelpCenters { + export import HelpCenterRetrieveParams = HelpCentersAPI.HelpCenterRetrieveParams; + export import HelpCenterListParams = HelpCentersAPI.HelpCenterListParams; +} diff --git a/src/resources/help-center/index.ts b/src/resources/help-center/index.ts new file mode 100644 index 00000000..6c9e3630 --- /dev/null +++ b/src/resources/help-center/index.ts @@ -0,0 +1,15 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + Collection, + CollectionList, + DeletedCollection, + CollectionCreateParams, + CollectionRetrieveParams, + CollectionUpdateParams, + CollectionListParams, + CollectionDeleteParams, + Collections, +} from './collections'; +export { HelpCenter, HelpCenterList, HelpCenterResource } from './help-center'; +export { HelpCenterRetrieveParams, HelpCenterListParams, HelpCenters } from './help-centers'; diff --git a/src/resources/index.ts b/src/resources/index.ts new file mode 100644 index 00000000..40a10ea9 --- /dev/null +++ b/src/resources/index.ts @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export * from './shared'; +export { AdminList, AdminRetrieveParams, AdminListParams, AdminSetAwayParams, Admins } from './admins/admins'; +export { AdminWithApp, MeRetrieveParams, Me } from './me'; +export { + Article, + ArticleList, + ArticleSearchResponse, + DeletedArticleObject, + ArticleCreateParams, + ArticleRetrieveParams, + ArticleUpdateParams, + ArticleListParams, + ArticleRemoveParams, + ArticleSearchParams, + Articles, +} from './articles'; +export { + CompanyList, + CompanyScroll, + DeletedCompanyObject, + CompanyCreateParams, + CompanyRetrieveParams, + CompanyUpdateParams, + CompanyListParams, + CompanyDeleteParams, + CompanyRetrieveListParams, + CompanyScrollParams, + Companies, +} from './companies/companies'; +export { + ContactArchived, + ContactDeleted, + ContactList, + ContactUnarchived, + ContactCreateParams, + ContactRetrieveParams, + ContactUpdateParams, + ContactListParams, + ContactDeleteParams, + ContactArchiveParams, + ContactMergeParams, + ContactSearchParams, + ContactUnarchiveParams, + Contacts, +} from './contacts/contacts'; +export { + ConversationListResponse, + ConversationSearchResponse, + ConversationCreateParams, + ConversationRetrieveParams, + ConversationUpdateParams, + ConversationListParams, + ConversationConvertParams, + ConversationRedactParams, + ConversationSearchParams, + ConversationListResponsesCursorPagination, + Conversations, +} from './conversations/conversations'; +export { + DataAttribute, + DataAttributeList, + DataAttributeCreateParams, + DataAttributeUpdateParams, + DataAttributeListParams, + DataAttributes, +} from './data-attributes'; +export { + DataEventSummary, + DataEventCreateParams, + DataEventListParams, + DataEventSummariesParams, + DataEvents, +} from './data-events'; +export { DataExport, DataExportContentDataParams, DataExports } from './data-exports'; +export { Download } from './download/download'; +export { ExportCancelParams, Export } from './export/export'; +export { HelpCenter, HelpCenterList, HelpCenterResource } from './help-center/help-center'; +export { MessageCreateParams, Messages } from './messages'; +export { News } from './news/news'; +export { NoteRetrieveParams, Notes } from './notes'; +export { PhoneSwitch, PhoneCallRedirectCreateParams, PhoneCallRedirects } from './phone-call-redirects'; +export { Segment, SegmentList, SegmentRetrieveParams, SegmentListParams, Segments } from './segments'; +export { SubscriptionTypeListParams, SubscriptionTypes } from './subscription-types'; +export { TagRetrieveParams, TagListParams, TagDeleteParams, TagCreateOrUpdateParams, Tags } from './tags'; +export { Team, TeamList, TeamRetrieveParams, TeamListParams, Teams } from './teams'; +export { + TicketList, + TicketReply, + TicketCreateParams, + TicketReplyParams, + TicketRetrieveByIDParams, + TicketSearchParams, + TicketUpdateByIDParams, + Tickets, +} from './tickets/tickets'; +export { + TicketType, + TicketTypeList, + TicketTypeCreateParams, + TicketTypeRetrieveParams, + TicketTypeUpdateParams, + TicketTypeListParams, + TicketTypes, +} from './ticket-types/ticket-types'; +export { + Visitor, + VisitorDeletedObject, + VisitorRetrieveParams, + VisitorUpdateParams, + VisitorConvertParams, + Visitors, +} from './visitors'; diff --git a/src/resources/me.ts b/src/resources/me.ts new file mode 100644 index 00000000..79a1ccba --- /dev/null +++ b/src/resources/me.ts @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as MeAPI from './me'; + +export class Me extends APIResource { + /** + * 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. + */ + retrieve(params?: MeRetrieveParams, options?: Core.RequestOptions): Core.APIPromise; + retrieve(options?: Core.RequestOptions): Core.APIPromise; + retrieve( + params: MeRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/me', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * Admins are the teammate accounts that have access to a workspace + */ +export interface AdminWithApp { + /** + * The id representing the admin. + */ + id?: string; + + /** + * App that the admin belongs to. + */ + app?: AdminWithApp.App | null; + + /** + * This object represents the avatar associated with the admin. + */ + avatar?: AdminWithApp.Avatar; + + /** + * 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 email of the admin. + */ + email?: string; + + /** + * Identifies if this admin's email is verified. + */ + email_verified?: boolean | null; + + /** + * Identifies if this admin has a paid inbox seat to restrict/allow features that + * require them. + */ + has_inbox_seat?: boolean; + + /** + * The job title of the admin. + */ + job_title?: string; + + /** + * The name of the admin. + */ + name?: string; + + /** + * This is a list of ids of the teams that this admin is part of. + */ + team_ids?: Array; + + /** + * String representing the object's type. Always has the value `admin`. + */ + type?: string; +} + +export namespace AdminWithApp { + /** + * App that the admin belongs to. + */ + export interface App { + /** + * When the app was created. + */ + created_at?: number; + + /** + * The id of the app. + */ + id_code?: string; + + /** + * Whether or not the app uses identity verification. + */ + identity_verification?: boolean; + + /** + * 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; + + type?: string; + } + + /** + * This object represents the avatar associated with the admin. + */ + export interface Avatar { + /** + * This object represents the avatar associated with the admin. + */ + image_url?: string | null; + + /** + * This is a string that identifies the type of the object. It will always have the + * value `avatar`. + */ + type?: string; + } +} + +export interface MeRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Me { + export import AdminWithApp = MeAPI.AdminWithApp; + export import MeRetrieveParams = MeAPI.MeRetrieveParams; +} diff --git a/src/resources/messages.ts b/src/resources/messages.ts new file mode 100644 index 00000000..8a72d8e8 --- /dev/null +++ b/src/resources/messages.ts @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; +import * as MessagesAPI from './messages'; +import * as Shared from './shared'; + +export class Messages extends APIResource { + /** + * You can create a message that has been initiated by an admin. The conversation + * can be either an in-app message or an email. + * + * > 🚧 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. + */ + create(params: MessageCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { body, 'Intercom-Version': intercomVersion } = params; + return this._client.post('/messages', { + body: body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export type MessageCreateParams = MessageCreateParams.MessageTypeEmail | MessageCreateParams.MessageTypeInapp; + +export namespace MessageCreateParams { + export interface MessageTypeEmail { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface MessageTypeInapp { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Messages { + export import MessageCreateParams = MessagesAPI.MessageCreateParams; +} diff --git a/src/resources/news/index.ts b/src/resources/news/index.ts new file mode 100644 index 00000000..1f665092 --- /dev/null +++ b/src/resources/news/index.ts @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { News } from './news'; +export { + NewsItem, + NewsItemListResponse, + NewsItemDeleteResponse, + NewsItemCreateParams, + NewsItemRetrieveParams, + NewsItemUpdateParams, + NewsItemListParams, + NewsItemDeleteParams, + NewsItems, +} from './news-items'; +export { + Newsfeed, + NewsfeedListResponse, + NewsfeedRetrieveParams, + NewsfeedListParams, + Newsfeeds, +} from './newsfeeds/index'; diff --git a/src/resources/news/news-items.ts b/src/resources/news/news-items.ts new file mode 100644 index 00000000..ab6635b9 --- /dev/null +++ b/src/resources/news/news-items.ts @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as NewsItemsAPI from './news-items'; +import * as Shared from '../shared'; +import * as NewsfeedsAPI from './newsfeeds/newsfeeds'; + +export class NewsItems extends APIResource { + /** + * You can create a news item + */ + create(params: NewsItemCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/news/news_items', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single news item. + */ + retrieve( + id: number, + params?: NewsItemRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: NewsItemRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/news/news_items/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * Update a news item + */ + update(id: number, params: NewsItemUpdateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/news/news_items/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all news items + */ + list(params?: NewsItemListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: NewsItemListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/news/news_items', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete a single news item. + */ + delete( + id: number, + params?: NewsItemDeleteParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + delete(id: number, options?: Core.RequestOptions): Core.APIPromise; + delete( + id: number, + params: NewsItemDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/news/news_items/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * 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 news item body, which may contain HTML. + */ + body?: string; + + /** + * URL of the image used as cover. Must have .jpg or .png extension. + */ + cover_image_url?: string | null; + + /** + * Timestamp for when the news item was created. + */ + created_at?: number; + + /** + * 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?: Array; + + /** + * A list of newsfeed_assignments to assign to the specified newsfeed. + */ + newsfeed_assignments?: Array; + + /** + * Ordered list of emoji reactions to the news item. When empty, reactions are + * disabled. + */ + reactions?: Array; + + /** + * 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?: 'draft' | 'live'; + + /** + * The title of the news item. + */ + title?: string; + + /** + * The type of object. + */ + type?: 'news-item'; + + /** + * Timestamp for when the news item was last updated. + */ + updated_at?: number; + + /** + * The id of the workspace which the news item belongs to. + */ + workspace_id?: string; +} + +export namespace NewsItem { + /** + * 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; + } +} + +/** + * Paginated Response + */ +export interface NewsItemListResponse { + /** + * An array of Objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * The type of object + */ + type?: 'list' | 'conversation.list'; +} + +/** + * Response returned when an object is deleted + */ +export interface NewsItemDeleteResponse { + /** + * The unique identifier for the news item which you provided in the URL. + */ + id?: string; + + /** + * Whether the news item was deleted successfully or not. + */ + deleted?: boolean; + + /** + * The type of object which was deleted - news-item. + */ + object?: 'news-item'; +} + +export interface NewsItemCreateParams { + /** + * Body param: The id of the sender of the news item. Must be a teammate on the + * workspace. + */ + sender_id: number; + + /** + * Body param: The title of the news item. + */ + title: string; + + /** + * Body param: The news item body, which may contain HTML. + */ + body?: string; + + /** + * Body param: When set to `true`, the news item will appear in the messenger + * newsfeed without showing a notification badge. + */ + deliver_silently?: boolean; + + /** + * Body param: Label names displayed to users to categorize the news item. + */ + labels?: Array; + + /** + * Body param: A list of newsfeed_assignments to assign to the specified newsfeed. + */ + newsfeed_assignments?: Array; + + /** + * Body param: Ordered list of emoji reactions to the news item. When empty, + * reactions are disabled. + */ + reactions?: Array; + + /** + * Body param: News items will not be visible to your users in the assigned + * newsfeeds until they are set live. + */ + state?: 'draft' | 'live'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace NewsItemCreateParams { + /** + * 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; + } +} + +export interface NewsItemRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface NewsItemUpdateParams { + /** + * Body param: The id of the sender of the news item. Must be a teammate on the + * workspace. + */ + sender_id: number; + + /** + * Body param: The title of the news item. + */ + title: string; + + /** + * Body param: The news item body, which may contain HTML. + */ + body?: string; + + /** + * Body param: When set to `true`, the news item will appear in the messenger + * newsfeed without showing a notification badge. + */ + deliver_silently?: boolean; + + /** + * Body param: Label names displayed to users to categorize the news item. + */ + labels?: Array; + + /** + * Body param: A list of newsfeed_assignments to assign to the specified newsfeed. + */ + newsfeed_assignments?: Array; + + /** + * Body param: Ordered list of emoji reactions to the news item. When empty, + * reactions are disabled. + */ + reactions?: Array; + + /** + * Body param: News items will not be visible to your users in the assigned + * newsfeeds until they are set live. + */ + state?: 'draft' | 'live'; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace NewsItemUpdateParams { + /** + * 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; + } +} + +export interface NewsItemListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface NewsItemDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace NewsItems { + export import NewsItem = NewsItemsAPI.NewsItem; + export import NewsItemListResponse = NewsItemsAPI.NewsItemListResponse; + export import NewsItemDeleteResponse = NewsItemsAPI.NewsItemDeleteResponse; + export import NewsItemCreateParams = NewsItemsAPI.NewsItemCreateParams; + export import NewsItemRetrieveParams = NewsItemsAPI.NewsItemRetrieveParams; + export import NewsItemUpdateParams = NewsItemsAPI.NewsItemUpdateParams; + export import NewsItemListParams = NewsItemsAPI.NewsItemListParams; + export import NewsItemDeleteParams = NewsItemsAPI.NewsItemDeleteParams; +} diff --git a/src/resources/news/news.ts b/src/resources/news/news.ts new file mode 100644 index 00000000..bb45b9e1 --- /dev/null +++ b/src/resources/news/news.ts @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as NewsItemsAPI from './news-items'; +import * as NewsfeedsAPI from './newsfeeds/newsfeeds'; + +export class News extends APIResource { + newsItems: NewsItemsAPI.NewsItems = new NewsItemsAPI.NewsItems(this._client); + newsfeeds: NewsfeedsAPI.Newsfeeds = new NewsfeedsAPI.Newsfeeds(this._client); +} + +export namespace News { + export import NewsItems = NewsItemsAPI.NewsItems; + export import NewsItem = NewsItemsAPI.NewsItem; + export import NewsItemListResponse = NewsItemsAPI.NewsItemListResponse; + export import NewsItemDeleteResponse = NewsItemsAPI.NewsItemDeleteResponse; + export import NewsItemCreateParams = NewsItemsAPI.NewsItemCreateParams; + export import NewsItemRetrieveParams = NewsItemsAPI.NewsItemRetrieveParams; + export import NewsItemUpdateParams = NewsItemsAPI.NewsItemUpdateParams; + export import NewsItemListParams = NewsItemsAPI.NewsItemListParams; + export import NewsItemDeleteParams = NewsItemsAPI.NewsItemDeleteParams; + export import Newsfeeds = NewsfeedsAPI.Newsfeeds; + export import Newsfeed = NewsfeedsAPI.Newsfeed; + export import NewsfeedListResponse = NewsfeedsAPI.NewsfeedListResponse; + export import NewsfeedRetrieveParams = NewsfeedsAPI.NewsfeedRetrieveParams; + export import NewsfeedListParams = NewsfeedsAPI.NewsfeedListParams; +} diff --git a/src/resources/news/newsfeeds/index.ts b/src/resources/news/newsfeeds/index.ts new file mode 100644 index 00000000..b88068f0 --- /dev/null +++ b/src/resources/news/newsfeeds/index.ts @@ -0,0 +1,10 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { ItemListResponse, ItemListParams, Items } from './items'; +export { + Newsfeed, + NewsfeedListResponse, + NewsfeedRetrieveParams, + NewsfeedListParams, + Newsfeeds, +} from './newsfeeds'; diff --git a/src/resources/news/newsfeeds/items.ts b/src/resources/news/newsfeeds/items.ts new file mode 100644 index 00000000..95904b2c --- /dev/null +++ b/src/resources/news/newsfeeds/items.ts @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; +import * as ItemsAPI from './items'; +import * as Shared from '../../shared'; +import * as NewsItemsAPI from '../news-items'; +import * as NewsfeedsAPI from './newsfeeds'; + +export class Items extends APIResource { + /** + * You can fetch a list of all news items that are live on a given newsfeed + */ + list(id: string, params?: ItemListParams, options?: Core.RequestOptions): Core.APIPromise; + list(id: string, options?: Core.RequestOptions): Core.APIPromise; + list( + id: string, + params: ItemListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/news/newsfeeds/${id}/items`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * Paginated Response + */ +export interface ItemListResponse { + /** + * An array of Objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * The type of object + */ + type?: 'list' | 'conversation.list'; +} + +export interface ItemListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Items { + export import ItemListResponse = ItemsAPI.ItemListResponse; + export import ItemListParams = ItemsAPI.ItemListParams; +} diff --git a/src/resources/news/newsfeeds/newsfeeds.ts b/src/resources/news/newsfeeds/newsfeeds.ts new file mode 100644 index 00000000..5a762628 --- /dev/null +++ b/src/resources/news/newsfeeds/newsfeeds.ts @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../resource'; +import { isRequestOptions } from '../../../core'; +import * as Core from '../../../core'; +import * as NewsfeedsAPI from './newsfeeds'; +import * as Shared from '../../shared'; +import * as NewsItemsAPI from '../news-items'; +import * as ItemsAPI from './items'; + +export class Newsfeeds extends APIResource { + items: ItemsAPI.Items = new ItemsAPI.Items(this._client); + + /** + * You can fetch the details of a single newsfeed + */ + retrieve( + id: string, + params?: NewsfeedRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: NewsfeedRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/news/newsfeeds/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all newsfeeds + */ + list(params?: NewsfeedListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: NewsfeedListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/news/newsfeeds', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * 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; + + /** + * Timestamp for when the newsfeed was created. + */ + created_at?: number; + + /** + * The name of the newsfeed. This name will never be visible to your users. + */ + name?: string; + + /** + * The type of object. + */ + type?: 'newsfeed'; + + /** + * Timestamp for when the newsfeed was last updated. + */ + updated_at?: number; +} + +/** + * Paginated Response + */ +export interface NewsfeedListResponse { + /** + * An array of Objects + */ + data?: Array; + + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * The type of object + */ + type?: 'list' | 'conversation.list'; +} + +export interface NewsfeedRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface NewsfeedListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Newsfeeds { + export import Newsfeed = NewsfeedsAPI.Newsfeed; + export import NewsfeedListResponse = NewsfeedsAPI.NewsfeedListResponse; + export import NewsfeedRetrieveParams = NewsfeedsAPI.NewsfeedRetrieveParams; + export import NewsfeedListParams = NewsfeedsAPI.NewsfeedListParams; + export import Items = ItemsAPI.Items; + export import ItemListResponse = ItemsAPI.ItemListResponse; + export import ItemListParams = ItemsAPI.ItemListParams; +} diff --git a/src/resources/notes.ts b/src/resources/notes.ts new file mode 100644 index 00000000..5d84af66 --- /dev/null +++ b/src/resources/notes.ts @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as NotesAPI from './notes'; +import * as Shared from './shared'; + +export class Notes extends APIResource { + /** + * You can fetch the details of a single note. + */ + retrieve( + id: number, + params?: NoteRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: number, + params: NoteRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/notes/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface NoteRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Notes { + export import NoteRetrieveParams = NotesAPI.NoteRetrieveParams; +} diff --git a/src/resources/phone-call-redirects.ts b/src/resources/phone-call-redirects.ts new file mode 100644 index 00000000..58263d42 --- /dev/null +++ b/src/resources/phone-call-redirects.ts @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; +import * as PhoneCallRedirectsAPI from './phone-call-redirects'; + +export class PhoneCallRedirects extends APIResource { + /** + * 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. + */ + create( + params: PhoneCallRedirectCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/phone_call_redirects', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * Phone Switch Response + */ +export interface PhoneSwitch { + /** + * Phone number in E.164 format, that has received the SMS to continue the + * conversation in the Messenger. + */ + phone?: string; + + type?: 'phone_call_redirect'; +} + +export interface PhoneCallRedirectCreateParams { + /** + * Body param: Phone number in E.164 format, that will receive the SMS to continue + * the conversation in the Messenger. + */ + phone: string; + + /** + * Body param: 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. + */ + custom_attributes?: Record; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace PhoneCallRedirectCreateParams { + /** + * 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 custom attributes you have set on the custom object instance. + */ + custom_attributes?: Record; + + /** + * The id you have defined for the custom object instance. + */ + external_id?: string; + + /** + * The identifier of the custom object type that defines the structure of the + * custom object instance. + */ + type?: string; + } +} + +export namespace PhoneCallRedirects { + export import PhoneSwitch = PhoneCallRedirectsAPI.PhoneSwitch; + export import PhoneCallRedirectCreateParams = PhoneCallRedirectsAPI.PhoneCallRedirectCreateParams; +} diff --git a/src/resources/segments.ts b/src/resources/segments.ts new file mode 100644 index 00000000..c2c6d9f3 --- /dev/null +++ b/src/resources/segments.ts @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as SegmentsAPI from './segments'; + +export class Segments extends APIResource { + /** + * You can fetch the details of a single segment. + */ + retrieve( + id: string, + params?: SegmentRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: SegmentRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/segments/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all segments. + */ + list(params?: SegmentListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: SegmentListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/segments', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A segment is a group of your contacts defined by the rules that you set. + */ +export interface Segment { + /** + * The unique identifier representing the segment. + */ + id?: string; + + /** + * The number of items in the user segment. It's returned when `include_count=true` + * is included in the request. + */ + count?: number | null; + + /** + * The time the segment was created. + */ + created_at?: number; + + /** + * The name of the segment. + */ + name?: string; + + /** + * Type of the contact: contact (lead) or user. + */ + person_type?: 'contact' | 'user'; + + /** + * The type of object. + */ + type?: 'segment'; + + /** + * The time the segment was updated. + */ + updated_at?: number; +} + +/** + * This will return a list of Segment Objects. The result may also have a pages + * object if the response is paginated. + */ +export interface SegmentList { + /** + * A pagination object, which may be empty, indicating no further pages to fetch. + */ + pages?: unknown; + + /** + * A list of Segment objects + */ + segments?: Array; + + /** + * The type of the object + */ + type?: 'segment.list'; +} + +export interface SegmentRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface SegmentListParams { + /** + * Query param: It includes the count of contacts that belong to each segment. + */ + include_count?: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Segments { + export import Segment = SegmentsAPI.Segment; + export import SegmentList = SegmentsAPI.SegmentList; + export import SegmentRetrieveParams = SegmentsAPI.SegmentRetrieveParams; + export import SegmentListParams = SegmentsAPI.SegmentListParams; +} diff --git a/src/resources/shared.ts b/src/resources/shared.ts new file mode 100644 index 00000000..f7886b44 --- /dev/null +++ b/src/resources/shared.ts @@ -0,0 +1,2609 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import * as Shared from './shared'; +import * as SegmentsAPI from './segments'; +import * as SubscriptionsAPI from './contacts/subscriptions'; +import * as TicketTypesAPI from './ticket-types/ticket-types'; + +/** + * Admins are teammate accounts that have access to a workspace. + */ +export interface Admin { + /** + * The id representing the admin. + */ + id?: string; + + /** + * Image for the associated team or teammate + */ + avatar?: string | null; + + /** + * 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 email of the admin. + */ + email?: string; + + /** + * Identifies if this admin has a paid inbox seat to restrict/allow features that + * require them. + */ + has_inbox_seat?: boolean; + + /** + * The job title of the admin. + */ + job_title?: string; + + /** + * The name of the admin. + */ + name?: string; + + /** + * This object represents the avatar associated with the admin. + */ + team_ids?: Array; + + /** + * Admin priority levels for teams + */ + team_priority_level?: Admin.TeamPriorityLevel | null; + + /** + * String representing the object's type. Always has the value `admin`. + */ + type?: string; +} + +export namespace Admin { + /** + * Admin priority levels for teams + */ + export interface TeamPriorityLevel { + /** + * The primary team ids for the team + */ + primary_team_ids?: Array | null; + + /** + * The secondary team ids for the team + */ + secondary_team_ids?: Array | null; + } +} + +/** + * The Content of an Article. + */ +export interface ArticleContent { + /** + * The ID of the author of the article. + */ + author_id?: number; + + /** + * The body of the article. + */ + body?: string; + + /** + * The time when the article was created (seconds). + */ + created_at?: number; + + /** + * The description of the article. + */ + description?: string; + + /** + * Whether the article is `published` or is a `draft` . + */ + state?: 'published' | 'draft'; + + /** + * The title of the article. + */ + title?: string; + + /** + * The type of object - `article_content` . + */ + type?: 'article_content' | null; + + /** + * The time when the article was last updated (seconds). + */ + updated_at?: number; + + /** + * The URL of the article. + */ + url?: string; +} + +/** + * 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 content of the article in Indonesian + */ + id?: ArticleContent | null; + + /** + * The content of the article in Arabic + */ + ar?: ArticleContent | null; + + /** + * The content of the article in Bulgarian + */ + bg?: ArticleContent | null; + + /** + * The content of the article in Bosnian + */ + bs?: ArticleContent | null; + + /** + * The content of the article in Catalan + */ + ca?: ArticleContent | null; + + /** + * The content of the article in Czech + */ + cs?: ArticleContent | null; + + /** + * The content of the article in Danish + */ + da?: ArticleContent | null; + + /** + * The content of the article in German + */ + de?: ArticleContent | null; + + /** + * The content of the article in Greek + */ + el?: ArticleContent | null; + + /** + * The content of the article in English + */ + en?: ArticleContent | null; + + /** + * The content of the article in Spanish + */ + es?: ArticleContent | null; + + /** + * The content of the article in Estonian + */ + et?: ArticleContent | null; + + /** + * The content of the article in Finnish + */ + fi?: ArticleContent | null; + + /** + * The content of the article in French + */ + fr?: ArticleContent | null; + + /** + * The content of the article in Hebrew + */ + he?: ArticleContent | null; + + /** + * The content of the article in Croatian + */ + hr?: ArticleContent | null; + + /** + * The content of the article in Hungarian + */ + hu?: ArticleContent | null; + + /** + * The content of the article in Italian + */ + it?: ArticleContent | null; + + /** + * The content of the article in Japanese + */ + ja?: ArticleContent | null; + + /** + * The content of the article in Korean + */ + ko?: ArticleContent | null; + + /** + * The content of the article in Lithuanian + */ + lt?: ArticleContent | null; + + /** + * The content of the article in Latvian + */ + lv?: ArticleContent | null; + + /** + * The content of the article in Mongolian + */ + mn?: ArticleContent | null; + + /** + * The content of the article in Norwegian + */ + nb?: ArticleContent | null; + + /** + * The content of the article in Dutch + */ + nl?: ArticleContent | null; + + /** + * The content of the article in Polish + */ + pl?: ArticleContent | null; + + /** + * The content of the article in Portuguese (Portugal) + */ + pt?: ArticleContent | null; + + /** + * The content of the article in Portuguese (Brazil) + */ + 'pt-BR'?: ArticleContent | null; + + /** + * The content of the article in Romanian + */ + ro?: ArticleContent | null; + + /** + * The content of the article in Russian + */ + ru?: ArticleContent | null; + + /** + * The content of the article in Slovenian + */ + sl?: ArticleContent | null; + + /** + * The content of the article in Serbian + */ + sr?: ArticleContent | null; + + /** + * The content of the article in Swedish + */ + sv?: ArticleContent | null; + + /** + * The content of the article in Turkish + */ + tr?: ArticleContent | null; + + /** + * The type of object - article_translated_content. + */ + type?: 'article_translated_content' | null; + + /** + * The content of the article in Vietnamese + */ + vi?: ArticleContent | null; + + /** + * The content of the article in Chinese (China) + */ + 'zh-CN'?: ArticleContent | null; + + /** + * The content of the article in Chinese (Taiwan) + */ + 'zh-TW'?: ArticleContent | null; +} + +/** + * 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 { + /** + * The Intercom defined id representing the company. + */ + id?: string; + + /** + * The Intercom defined code of the workspace the company is associated to. + */ + app_id?: string; + + /** + * The company id you have defined for the company. + */ + company_id?: string; + + /** + * The time the company was added in Intercom. + */ + created_at?: number; + + /** + * The custom attributes you have set on the company. + */ + custom_attributes?: Record; + + /** + * The industry that the company operates in. + */ + industry?: string; + + /** + * The time the company last recorded making a request. + */ + last_request_at?: number; + + /** + * How much revenue the company generates for your business. + */ + monthly_spend?: number; + + /** + * The name of the company. + */ + name?: string; + + plan?: Company.Plan; + + /** + * The time the company was created by you. + */ + remote_created_at?: number; + + /** + * The list of segments associated with the company + */ + segments?: Company.Segments; + + /** + * How many sessions the company has recorded. + */ + session_count?: number; + + /** + * The number of employees in the company. + */ + size?: number; + + /** + * The list of tags associated with the company + */ + tags?: Company.Tags; + + /** + * Value is `company` + */ + type?: 'company'; + + /** + * The last time the company was updated. + */ + updated_at?: number; + + /** + * The number of users in the company. + */ + user_count?: number; + + /** + * The URL for the company website. + */ + website?: string; +} + +export namespace Company { + export interface Plan { + /** + * The id of the plan + */ + id?: string; + + /** + * The name of the plan + */ + name?: string; + + /** + * Value is always "plan" + */ + type?: string; + } + + /** + * The list of segments associated with the company + */ + export interface Segments { + segments?: Array; + + /** + * The type of the object + */ + type?: 'segment.list'; + } + + /** + * The list of tags associated with the company + */ + export interface Tags { + tags?: Array; + + /** + * The type of the object + */ + type?: 'tag.list'; + } +} + +/** + * Contact are the objects that represent your leads and users in Intercom. + */ +export interface Contact { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * The name of the Android app which the contact is using. + */ + android_app_name?: string | null; + + /** + * The version of the Android app which the contact is using. + */ + android_app_version?: string | null; + + /** + * The Android device which the contact is using. + */ + android_device?: string | null; + + /** + * (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + android_last_seen_at?: number | null; + + /** + * The version of the Android OS which the contact is using. + */ + android_os_version?: string | null; + + /** + * The version of the Android SDK which the contact is using. + */ + android_sdk_version?: string | null; + + avatar?: Contact.Avatar | null; + + /** + * The name of the browser which the contact is using. + */ + browser?: string | null; + + /** + * The language set by the browser which the contact is using. + */ + browser_language?: string | null; + + /** + * The version of the browser which the contact is using. + */ + browser_version?: string | null; + + /** + * An object containing companies meta data about the companies that a contact has. + * Up to 10 will be displayed here. Use the url to get more. + */ + companies?: Contact.Companies; + + /** + * (UNIX timestamp) The time when the contact was created. + */ + created_at?: number; + + /** + * The custom attributes which are set for the contact. + */ + custom_attributes?: unknown; + + /** + * The contact's email. + */ + email?: string; + + /** + * The contact's email domain. + */ + email_domain?: string; + + /** + * The unique identifier for the contact which is provided by the Client. + */ + external_id?: string | null; + + /** + * The contacts phone number normalized to the E164 format + */ + formatted_phone?: string | null; + + /** + * Whether the contact has had an email sent to them hard bounce. + */ + has_hard_bounced?: boolean; + + /** + * The name of the iOS app which the contact is using. + */ + ios_app_name?: string | null; + + /** + * The version of the iOS app which the contact is using. + */ + ios_app_version?: string | null; + + /** + * The iOS device which the contact is using. + */ + ios_device?: string | null; + + /** + * (UNIX timestamp) The last time the contact used the iOS app. + */ + ios_last_seen_at?: number | null; + + /** + * The version of iOS which the contact is using. + */ + ios_os_version?: string | null; + + /** + * The version of the iOS SDK which the contact is using. + */ + ios_sdk_version?: string | null; + + /** + * A preferred language setting for the contact, used by the Intercom Messenger + * even if their browser settings change. + */ + language_override?: string | null; + + /** + * (UNIX timestamp) The time when the contact was last messaged. + */ + last_contacted_at?: number | null; + + /** + * (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + last_email_clicked_at?: number | null; + + /** + * (UNIX timestamp) The time when the contact last opened an email. + */ + last_email_opened_at?: number | null; + + /** + * (UNIX timestamp) The time when the contact last messaged in. + */ + last_replied_at?: number | null; + + /** + * (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 | null; + + /** + * An object containing location meta data about a Intercom contact. + */ + location?: Contact.Location; + + /** + * Whether the contact has marked an email sent to them as spam. + */ + marked_email_as_spam?: boolean; + + /** + * The contacts name. + */ + name?: string | null; + + /** + * 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. + */ + notes?: Contact.Notes; + + /** + * The operating system which the contact is using. + */ + os?: string | null; + + /** + * The id of an admin that has been assigned account ownership of the contact. + */ + owner_id?: number | null; + + /** + * The contacts phone. + */ + phone?: string | null; + + /** + * The role of the contact. + */ + role?: string; + + /** + * (UNIX timestamp) The time specified for when a contact signed up. + */ + signed_up_at?: number | null; + + /** + * An object containing social profiles that a contact has. + */ + social_profiles?: Contact.SocialProfiles; + + /** + * 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. + */ + tags?: Contact.Tags | null; + + /** + * The type of object. + */ + type?: string; + + /** + * Whether the contact is unsubscribed from emails. + */ + unsubscribed_from_emails?: boolean; + + /** + * (UNIX timestamp) The time when the contact was last updated. + */ + updated_at?: number; + + /** + * The id of the workspace which the contact belongs to. + */ + workspace_id?: string; +} + +export namespace Contact { + export interface Avatar { + /** + * An image URL containing the avatar of a contact. + */ + image_url?: string | null; + + /** + * The type of object + */ + type?: string; + } + + /** + * An object containing companies meta data about the companies that a contact has. + * Up to 10 will be displayed here. Use the url to get more. + */ + export interface Companies { + /** + * Whether there's more Addressable Objects to be viewed. If true, use the url to + * view all + */ + has_more?: boolean; + + /** + * Int representing the total number of companyies attached to this contact + */ + total_count?: number; + + /** + * Url to get more company resources for this contact + */ + url?: string; + } + + /** + * An object containing location meta data about a Intercom contact. + */ + export interface Location { + /** + * The city that the contact is located in + */ + city?: string | null; + + /** + * The country that the contact is located in + */ + country?: string | null; + + /** + * The overal region that the contact is located in + */ + region?: string | null; + + /** + * Always location + */ + type?: string | null; + } + + /** + * 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 Notes { + /** + * This object represents the notes attached to a contact. + */ + data?: Array; + + /** + * Whether there's more Addressable Objects to be viewed. If true, use the url to + * view all + */ + has_more?: boolean; + + /** + * Int representing the total number of companyies attached to this contact + */ + total_count?: number; + + /** + * Url to get more company resources for this contact + */ + url?: string; + } + + export namespace Notes { + /** + * A list used to access other resources from a parent model. + */ + export interface Data { + /** + * The id of the addressable object + */ + id?: string; + + /** + * The addressable object type + */ + type?: string; + + /** + * Url to get more company resources for this contact + */ + url?: string; + } + } + + /** + * An object containing social profiles that a contact has. + */ + export interface SocialProfiles { + /** + * A list of social profiles objects associated with the contact. + */ + data?: Array; + } + + export namespace SocialProfiles { + /** + * A Social Profile allows you to label your contacts, companies, and conversations + * and list them using that Social Profile. + */ + export interface Data { + /** + * The name of the Social media profile + */ + name?: string; + + /** + * value is "social_profile" + */ + type?: string; + + /** + * The name of the Social media profile + */ + url?: string; + } + } + + /** + * 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 Tags { + /** + * This object represents the tags attached to a contact. + */ + data?: Array; + + /** + * Whether there's more Addressable Objects to be viewed. If true, use the url to + * view all + */ + has_more?: boolean; + + /** + * Int representing the total number of tags attached to this contact + */ + total_count?: number; + + /** + * url to get more tag resources for this contact + */ + url?: string; + } + + export namespace Tags { + /** + * A list used to access other resources from a parent model. + */ + export interface Data { + /** + * The id of the addressable object + */ + id?: string; + + /** + * The addressable object type + */ + type?: string; + + /** + * Url to get more company resources for this contact + */ + url?: string; + } + } +} + +/** + * reference to contact object + */ +export interface ContactReference { + /** + * 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 | null; + + /** + * always contact + */ + type?: 'contact'; +} + +/** + * 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 { + /** + * The id representing the conversation. + */ + id?: string; + + /** + * 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 | null; + + /** + * Data related to AI Agent involvement in the conversation. + */ + ai_agent?: Conversation.AIAgent | null; + + /** + * Indicates whether the AI Agent participated in the conversation. + */ + ai_agent_participated?: boolean; + + /** + * 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?: Conversation.Contacts; + + /** + * 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?: Conversation.ConversationParts; + + /** + * The Conversation Rating object which contains information on the rating and/or + * remark added by a Contact and the Admin assigned to the conversation. + */ + conversation_rating?: Conversation.ConversationRating | null; + + /** + * The time the conversation was created. + */ + created_at?: number; + + /** + * 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. + */ + custom_attributes?: Record; + + /** + * An object containing information on the first users message. For a contact + * initiated message this will represent the users original message. + */ + first_contact_reply?: Conversation.FirstContactReply | null; + + /** + * An object containing metadata about linked conversations and linked tickets. Up + * to 1000 can be returned. + */ + linked_objects?: Conversation.LinkedObjects; + + /** + * Indicates whether a conversation is open (true) or closed (false). + */ + open?: boolean; + + /** + * If marked as priority, it will return priority or else not_priority. + */ + priority?: 'priority' | 'not_priority'; + + /** + * Indicates whether a conversation has been read. + */ + read?: boolean; + + /** + * 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. + */ + sla_applied?: Conversation.SlaApplied | null; + + /** + * 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 | null; + + /** + * The Conversation Part that originated this conversation, which can be Contact, + * Admin, Campaign, Automated or Operator initiated. + */ + source?: Conversation.Source; + + /** + * Can be set to "open", "closed" or "snoozed". + */ + state?: 'open' | 'closed' | 'snoozed'; + + /** + * A Statistics object containing all information required for reporting, with + * timestamps and calculated metrics. + */ + statistics?: Conversation.Statistics | null; + + /** + * A list of tags objects associated with a conversation + */ + tags?: Conversation.Tags; + + /** + * 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 | null; + + /** + * The list of teammates who participated in the conversation (wrote at least one + * conversation part). + */ + teammates?: Conversation.Teammates | null; + + /** + * The title given to the conversation. + */ + title?: string | null; + + /** + * Always conversation. + */ + type?: string; + + /** + * 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 | null; +} + +export namespace Conversation { + /** + * Data related to AI Agent involvement in the conversation. + */ + export interface AIAgent { + content_sources?: AIAgent.ContentSources; + + /** + * The type of the last answer delviered by AI Agent. If no answer was delivered + * then this will return null + */ + last_answer_type?: 'ai_answer' | 'custom_answer' | null; + + /** + * 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; + + /** + * The resolution state of AI Agent. If no AI or custom answer has been delivered + * then this will return `abandoned`. + */ + resolution_state?: 'assumed_resolution' | 'confirmed_resolution' | 'routed_to_team' | 'abandoned'; + + /** + * 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 | null; + + /** + * The type of the source that triggered AI Agent involvement in the conversation. + */ + source_type?: 'essentials_plan_setup' | 'profile' | 'workflow' | 'workflow_preview' | 'fin_preview'; + } + + export namespace AIAgent { + export interface ContentSources { + /** + * The content sources used by AI Agent in the conversation. + */ + content_sources?: Array; + + /** + * The total number of content sources used by AI Agent in the conversation. + */ + total_count?: number; + + type?: 'content_source.list'; + } + + export namespace ContentSources { + /** + * The content source used by AI Agent in the conversation. + */ + export interface ContentSource { + /** + * The type of the content source. + */ + content_type?: + | 'file' + | 'article' + | 'external_content' + | 'content_snippet' + | 'workflow_connector_action'; + + /** + * The ISO 639 language code of the content source. + */ + locale?: string; + + /** + * The title of the content source. + */ + title?: string; + + /** + * The internal URL linking to the content source for teammates. + */ + url?: string; + } + } + } + + /** + * 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 Contacts { + /** + * The list of contacts (users or leads) involved in this conversation. This will + * only contain one customer unless more were added via the group conversation + * feature. + */ + contacts?: Array; + + type?: 'contact.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. + */ + export interface ConversationParts { + /** + * A list of Conversation Part objects for each part message in the conversation. + * This is only returned when Retrieving a Conversation, and ignored when Listing + * all Conversations. There is a limit of 500 parts. + */ + conversation_parts?: Array; + + total_count?: number; + + type?: 'conversation_part.list'; + } + + export namespace ConversationParts { + /** + * A Conversation Part represents a message in the conversation. + */ + export interface ConversationPart { + /** + * The id representing the conversation part. + */ + id?: string; + + /** + * 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?: Shared.Reference | null; + + /** + * A list of attachments for the part. + */ + attachments?: Array; + + /** + * 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. + */ + author?: ConversationPart.Author; + + /** + * The message body, which may contain HTML. For Twitter, this will show a generic + * message regarding why the body is obscured. + */ + body?: string | null; + + /** + * The time the conversation part was created. + */ + created_at?: number; + + /** + * The external id of the conversation part + */ + external_id?: string | null; + + /** + * The time the user was notified with the conversation part. + */ + notified_at?: number; + + /** + * The type of conversation part. + */ + part_type?: string; + + /** + * Whether or not the conversation part has been redacted. + */ + redacted?: boolean; + + /** + * Always conversation_part + */ + type?: string; + + /** + * The last time the conversation part was updated. + */ + updated_at?: number; + } + + export namespace ConversationPart { + /** + * 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 Author { + /** + * The id of the author + */ + id?: string; + + /** + * The email of the author + */ + email?: string; + + /** + * The name of the author + */ + name?: string; + + /** + * The type of the author + */ + type?: string; + } + } + } + + /** + * 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 { + /** + * reference to contact object + */ + contact?: Shared.ContactReference; + + /** + * The time the rating was requested in the conversation being rated. + */ + created_at?: number; + + /** + * 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; + + /** + * reference to another object + */ + teammate?: Shared.Reference; + } + + /** + * 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 custom attributes you have set on the custom object instance. + */ + custom_attributes?: Record; + + /** + * The id you have defined for the custom object instance. + */ + external_id?: string; + + /** + * The identifier of the custom object type that defines the structure of the + * custom object instance. + */ + type?: string; + } + + /** + * An object containing information on the first users message. For a contact + * initiated message this will represent the users original message. + */ + export interface FirstContactReply { + created_at?: number; + + type?: string; + + url?: string | null; + } + + /** + * An object containing metadata about linked conversations and linked tickets. Up + * to 1000 can be returned. + */ + export interface LinkedObjects { + /** + * An array containing the linked conversations and linked tickets. + */ + data?: Array; + + /** + * Whether or not there are more linked objects than returned. + */ + has_more?: boolean; + + /** + * The total number of linked objects. + */ + total_count?: number; + + /** + * Always list. + */ + type?: 'list'; + } + + export namespace LinkedObjects { + /** + * A linked conversation or ticket. + */ + export interface Data { + /** + * The ID of the linked object + */ + id?: string; + + /** + * Category of the Linked Ticket Object. + */ + category?: 'Customer' | 'Back-office' | 'Tracker' | null; + + /** + * ticket or conversation + */ + type?: 'ticket' | 'conversation'; + } + } + + /** + * 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 { + /** + * 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?: 'hit' | 'missed' | 'cancelled' | 'active'; + + /** + * object type + */ + type?: string; + } + + /** + * The Conversation Part that originated this conversation, which can be Contact, + * Admin, Campaign, Automated or Operator initiated. + */ + export interface Source { + /** + * The id representing the message. + */ + id?: string; + + /** + * A list of attachments for the part. + */ + attachments?: Array; + + /** + * 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. + */ + author?: Source.Author; + + /** + * The message body, which may contain HTML. For Twitter, this will show a generic + * message regarding why the body is obscured. + */ + body?: 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; + + /** + * Whether or not the source message has been redacted. Only applicable for contact + * initiated messages. + */ + redacted?: boolean; + + /** + * Optional. The message subject. For Twitter, this will show a generic message + * regarding why the subject is obscured. + */ + subject?: string; + + /** + * This includes conversation, email, facebook, instagram, phone_call, + * phone_switch, push, sms, twitter and whatsapp. + */ + type?: string; + + /** + * The URL where the conversation was started. For Twitter, Email, and Bots, this + * will be blank. + */ + url?: string | null; + } + + export namespace Source { + /** + * 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 Author { + /** + * The id of the author + */ + id?: string; + + /** + * The email of the author + */ + email?: string; + + /** + * The name of the author + */ + name?: string; + + /** + * The type of the author + */ + type?: string; + } + } + + /** + * A Statistics object containing all information required for reporting, with + * timestamps and calculated metrics. + */ + export interface Statistics { + /** + * Number of assignments after first_contact_reply_at. + */ + count_assignments?: number; + + /** + * Total number of conversation parts. + */ + count_conversation_parts?: number; + + /** + * Number of reopens after first_contact_reply_at. + */ + count_reopens?: number; + + /** + * Time of first admin reply after first_contact_reply_at. + */ + first_admin_reply_at?: number; + + /** + * Time of first assignment after first_contact_reply_at. + */ + first_assignment_at?: number; + + /** + * Time of first close after first_contact_reply_at. + */ + first_close_at?: number; + + /** + * Time of first text conversation part from a contact. + */ + first_contact_reply_at?: number; + + /** + * Time of the last conversation part from an admin. + */ + last_admin_reply_at?: number; + + /** + * Time of first admin reply since most recent assignment. + */ + last_assignment_admin_reply_at?: number; + + /** + * Time of last assignment after first_contact_reply_at. + */ + last_assignment_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; + + /** + * Time of the last conversation part from a contact. + */ + last_contact_reply_at?: number; + + /** + * Median based on all admin replies after a contact reply. Subtracts out of + * business hours. In seconds. + */ + median_time_to_reply?: number; + + /** + * Duration until first admin reply. Subtracts out of business hours. In seconds. + */ + time_to_admin_reply?: number; + + /** + * Duration until last assignment before first admin reply. In seconds. + */ + time_to_assignment?: 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; + + type?: string; + } + + /** + * A list of tags objects associated with a conversation + */ + export interface Tags { + /** + * A list of tags objects associated with the conversation. + */ + tags?: Array; + + /** + * The type of the object + */ + type?: 'tag.list'; + } + + /** + * The list of teammates who participated in the conversation (wrote at least one + * conversation part). + */ + export interface Teammates { + /** + * The list of teammates who participated in the conversation (wrote at least one + * conversation part). + */ + teammates?: Array; + + /** + * The type of the object - `admin.list`. + */ + type?: string; + } +} + +/** + * 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 { + next?: StartingAfterPaging | null; + + /** + * The current page + */ + page?: number; + + /** + * Number of results per page + */ + per_page?: number; + + /** + * Total number of pages + */ + total_pages?: number; + + /** + * the type of object `pages`. + */ + type?: 'pages'; +} + +/** + * The Content of a Group. + */ +export interface GroupContent { + /** + * The description of the collection. Only available for collections. + */ + description?: string; + + /** + * The name of the collection or section. + */ + name?: string; + + /** + * The type of object - `group_content` . + */ + type?: 'group_content' | null; +} + +/** + * 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 content of the group in Indonesian + */ + id?: GroupContent | null; + + /** + * The content of the group in Arabic + */ + ar?: GroupContent | null; + + /** + * The content of the group in Bulgarian + */ + bg?: GroupContent | null; + + /** + * The content of the group in Bosnian + */ + bs?: GroupContent | null; + + /** + * The content of the group in Catalan + */ + ca?: GroupContent | null; + + /** + * The content of the group in Czech + */ + cs?: GroupContent | null; + + /** + * The content of the group in Danish + */ + da?: GroupContent | null; + + /** + * The content of the group in German + */ + de?: GroupContent | null; + + /** + * The content of the group in Greek + */ + el?: GroupContent | null; + + /** + * The content of the group in English + */ + en?: GroupContent | null; + + /** + * The content of the group in Spanish + */ + es?: GroupContent | null; + + /** + * The content of the group in Estonian + */ + et?: GroupContent | null; + + /** + * The content of the group in Finnish + */ + fi?: GroupContent | null; + + /** + * The content of the group in French + */ + fr?: GroupContent | null; + + /** + * The content of the group in Hebrew + */ + he?: GroupContent | null; + + /** + * The content of the group in Croatian + */ + hr?: GroupContent | null; + + /** + * The content of the group in Hungarian + */ + hu?: GroupContent | null; + + /** + * The content of the group in Italian + */ + it?: GroupContent | null; + + /** + * The content of the group in Japanese + */ + ja?: GroupContent | null; + + /** + * The content of the group in Korean + */ + ko?: GroupContent | null; + + /** + * The content of the group in Lithuanian + */ + lt?: GroupContent | null; + + /** + * The content of the group in Latvian + */ + lv?: GroupContent | null; + + /** + * The content of the group in Mongolian + */ + mn?: GroupContent | null; + + /** + * The content of the group in Norwegian + */ + nb?: GroupContent | null; + + /** + * The content of the group in Dutch + */ + nl?: GroupContent | null; + + /** + * The content of the group in Polish + */ + pl?: GroupContent | null; + + /** + * The content of the group in Portuguese (Portugal) + */ + pt?: GroupContent | null; + + /** + * The content of the group in Portuguese (Brazil) + */ + 'pt-BR'?: GroupContent | null; + + /** + * The content of the group in Romanian + */ + ro?: GroupContent | null; + + /** + * The content of the group in Russian + */ + ru?: GroupContent | null; + + /** + * The content of the group in Slovenian + */ + sl?: GroupContent | null; + + /** + * The content of the group in Serbian + */ + sr?: GroupContent | null; + + /** + * The content of the group in Swedish + */ + sv?: GroupContent | null; + + /** + * The content of the group in Turkish + */ + tr?: GroupContent | null; + + /** + * The type of object - group_translated_content. + */ + type?: 'group_translated_content' | null; + + /** + * The content of the group in Vietnamese + */ + vi?: GroupContent | null; + + /** + * The content of the group in Chinese (China) + */ + 'zh-CN'?: GroupContent | null; + + /** + * The content of the group in Chinese (Taiwan) + */ + 'zh-TW'?: GroupContent | null; +} + +/** + * 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 id representing the message. + */ + id: string; + + /** + * The message body, which may contain HTML. + */ + body: string; + + /** + * The time the conversation was created. + */ + created_at: number; + + /** + * The type of message that was sent. Can be email, inapp, facebook or twitter. + */ + message_type: 'email' | 'inapp' | 'facebook' | 'twitter'; + + /** + * The type of the message + */ + type: string; + + /** + * The associated conversation_id + */ + conversation_id?: string; + + /** + * The subject of the message. Only present if message_type: email. + */ + subject?: string; +} + +/** + * Search using Intercoms Search APIs with more than one filter. + */ +export interface MultipleFilterSearchRequest { + /** + * An operator to allow boolean inspection between multiple fields. + */ + operator?: 'AND' | 'OR'; + + /** + * Add mutiple filters. + */ + value?: Array | Array; +} + +/** + * Notes allow you to annotate and comment on your contacts. + */ +export interface Note { + /** + * The id of the note. + */ + id?: string; + + /** + * Optional. Represents the Admin that created the note. + */ + author?: Admin | null; + + /** + * The body text of the note. + */ + body?: string; + + /** + * Represents the contact that the note was created about. + */ + contact?: Note.Contact | null; + + /** + * The time the note was created. + */ + created_at?: number; + + /** + * String representing the object's type. Always has the value `note`. + */ + type?: string; +} + +export namespace Note { + /** + * Represents the contact that the note was created about. + */ + export interface Contact { + /** + * The id of the contact. + */ + id?: string; + + /** + * String representing the object's type. Always has the value `contact`. + */ + type?: string; + } +} + +/** + * The file attached to a part + */ +export interface PartAttachment { + /** + * The content type of the attachment + */ + content_type?: string; + + /** + * The size of the attachment + */ + filesize?: number; + + /** + * The height of the attachment + */ + height?: number; + + /** + * The name of the attachment + */ + name?: string; + + /** + * The type of attachment + */ + type?: string; + + /** + * The URL of the attachment + */ + url?: string; + + /** + * The width of the attachment + */ + width?: number; +} + +/** + * reference to another object + */ +export interface Reference { + id?: string | null; + + type?: string; +} + +/** + * Search using Intercoms Search APIs. + */ +export interface SearchRequest { + /** + * Search using Intercoms Search APIs with a single filter. + */ + query: SingleFilterSearchRequest | MultipleFilterSearchRequest; + + pagination?: StartingAfterPaging | null; +} + +/** + * 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?: '=' | '!=' | 'IN' | 'NIN' | '<' | '>' | '~' | '!~' | '^' | '$'; + + /** + * The value that you want to search on. + */ + value?: string; +} + +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 | null; +} + +/** + * A list of subscription type objects. + */ +export interface SubscriptionTypeList { + /** + * A list of subscription type objects associated with the workspace . + */ + data?: Array; + + /** + * The type of the object + */ + type?: 'list'; +} + +/** + * A tag allows you to label your contacts, companies, and conversations and list + * them using that tag. + */ +export interface Tag { + /** + * The id of the tag + */ + id?: string; + + /** + * The time when the tag was applied to the object + */ + applied_at?: number; + + /** + * reference to another object + */ + applied_by?: Reference; + + /** + * The name of the tag + */ + name?: string; + + /** + * value is "tag" + */ + type?: string; +} + +/** + * A list of tags objects in the workspace. + */ +export interface TagList { + /** + * A list of tags objects associated with the workspace . + */ + data?: Array; + + /** + * The type of the object + */ + type?: 'list'; +} + +/** + * Tickets are how you track requests from your users. + */ +export interface Ticket { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + id?: string; + + /** + * The id representing the admin assigned to the ticket. + */ + admin_assignee_id?: string; + + /** + * Category of the Ticket. + */ + category?: 'Customer' | 'Back-office' | 'Tracker'; + + /** + * The list of contacts affected by a ticket. + */ + contacts?: Ticket.Contacts; + + /** + * The time the ticket was created as a UTC Unix timestamp. + */ + created_at?: number; + + /** + * Whether or not the ticket is shared with the customer. + */ + is_shared?: boolean; + + /** + * An object containing metadata about linked conversations and linked tickets. Up + * to 1000 can be returned. + */ + linked_objects?: Ticket.LinkedObjects; + + /** + * 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; + + /** + * The id representing the team assigned to the ticket. + */ + team_assignee_id?: string; + + /** + * 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_`. + */ + ticket_attributes?: Record< + string, + string | null | number | boolean | Array | Ticket.FileAttribute + >; + + /** + * The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use + * ticket_id for API queries. + */ + ticket_id?: string; + + /** + * A list of Ticket Part objects for each note and event in the ticket. There is a + * limit of 500 parts. + */ + ticket_parts?: Ticket.TicketParts; + + /** + * The state the ticket is currenly in + */ + ticket_state?: 'submitted' | 'in_progress' | 'waiting_on_customer' | 'resolved'; + + /** + * The state the ticket is currently in, in a human readable form - visible to + * customers, in the messenger, email and tickets portal. + */ + ticket_state_external_label?: string; + + /** + * The state the ticket is currently in, in a human readable form - visible in + * Intercom + */ + ticket_state_internal_label?: string; + + /** + * A ticket type, used to define the data fields to be captured in a ticket. + */ + ticket_type?: TicketTypesAPI.TicketType | null; + + /** + * Always ticket + */ + type?: 'ticket'; + + /** + * The last time the ticket was updated as a UTC Unix timestamp. + */ + updated_at?: number; +} + +export namespace Ticket { + /** + * The list of contacts affected by a ticket. + */ + export interface Contacts { + /** + * The list of contacts affected by this ticket. + */ + contacts?: Array; + + /** + * always contact.list + */ + type?: 'contact.list'; + } + + /** + * An object containing metadata about linked conversations and linked tickets. Up + * to 1000 can be returned. + */ + export interface LinkedObjects { + /** + * An array containing the linked conversations and linked tickets. + */ + data?: Array; + + /** + * Whether or not there are more linked objects than returned. + */ + has_more?: boolean; + + /** + * The total number of linked objects. + */ + total_count?: number; + + /** + * Always list. + */ + type?: 'list'; + } + + export namespace LinkedObjects { + /** + * A linked conversation or ticket. + */ + export interface Data { + /** + * The ID of the linked object + */ + id?: string; + + /** + * Category of the Linked Ticket Object. + */ + category?: 'Customer' | 'Back-office' | 'Tracker' | null; + + /** + * ticket or conversation + */ + type?: 'ticket' | 'conversation'; + } + } + + /** + * The value describing a file upload set for a custom attribute + */ + export interface FileAttribute { + /** + * The type of file + */ + content_type?: string; + + /** + * The size of the file in bytes + */ + filesize?: number; + + /** + * The height of the file in pixels, if applicable + */ + height?: number; + + /** + * The name of the file + */ + name?: string; + + type?: string; + + /** + * The url of the file. This is a temporary URL and will expire after 30 minutes. + */ + url?: string; + + /** + * The width of the file in pixels, if applicable + */ + width?: number; + } + + /** + * A list of Ticket Part objects for each note and event in the ticket. There is a + * limit of 500 parts. + */ + export interface TicketParts { + /** + * A list of Ticket Part objects for each ticket. There is a limit of 500 parts. + */ + ticket_parts?: Array; + + total_count?: number; + + type?: 'ticket_part.list'; + } + + export namespace TicketParts { + /** + * A Ticket Part represents a message in the ticket. + */ + export interface TicketPart { + /** + * The id representing the ticket part. + */ + id?: string; + + /** + * 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?: Shared.Reference | null; + + /** + * A list of attachments for the part. + */ + attachments?: Array; + + /** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ + author?: TicketPart.Author; + + /** + * The message body, which may contain HTML. + */ + body?: string | null; + + /** + * The time the ticket part was created. + */ + created_at?: number; + + /** + * The external id of the ticket part + */ + external_id?: string | null; + + /** + * The type of ticket part. + */ + part_type?: string; + + /** + * The previous state of the ticket. + */ + previous_ticket_state?: 'submitted' | 'in_progress' | 'waiting_on_customer' | 'resolved'; + + /** + * Whether or not the ticket part has been redacted. + */ + redacted?: boolean; + + /** + * The state of the ticket. + */ + ticket_state?: 'submitted' | 'in_progress' | 'waiting_on_customer' | 'resolved'; + + /** + * Always ticket_part + */ + type?: string; + + /** + * The last time the ticket part was updated. + */ + updated_at?: number; + } + + export namespace TicketPart { + /** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ + export interface Author { + /** + * The id of the author + */ + id?: string; + + /** + * The email of the author + */ + email?: string; + + /** + * The name of the author + */ + name?: string | null; + + /** + * The type of the author + */ + type?: 'admin' | 'bot' | 'team' | 'user'; + } + } + } +} + +/** + * Ticket type attribute, used to define each data field to be captured in a + * ticket. + */ +export interface TicketTypeAttribute { + /** + * The id representing the ticket type attribute. + */ + id?: string; + + /** + * 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 type of the data attribute (allowed values: "string list integer decimal + * boolean datetime files") + */ + data_type?: string; + + /** + * Whether the attribute is built in or not. + */ + default?: boolean; + + /** + * The description of the ticket type attribute + */ + description?: string; + + /** + * Input options for the attribute + */ + input_options?: unknown; + + /** + * The name of the ticket type attribute + */ + name?: string; + + /** + * 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; + + /** + * The id of the ticket type that the attribute belongs to. + */ + ticket_type_id?: number; + + /** + * String representing the object's type. Always has the value + * `ticket_type_attribute`. + */ + type?: string; + + /** + * The date and time the ticket type attribute was last updated. + */ + updated_at?: number; + + /** + * 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; + + /** + * The id of the workspace that the ticket type attribute belongs to. + */ + workspace_id?: string; +} diff --git a/src/resources/subscription-types.ts b/src/resources/subscription-types.ts new file mode 100644 index 00000000..fcbfb27d --- /dev/null +++ b/src/resources/subscription-types.ts @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as SubscriptionTypesAPI from './subscription-types'; +import * as Shared from './shared'; + +export class SubscriptionTypes extends APIResource { + /** + * You can list all subscription types. A list of subscription type objects will be + * returned. + */ + list( + params?: SubscriptionTypeListParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: SubscriptionTypeListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/subscription_types', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface SubscriptionTypeListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace SubscriptionTypes { + export import SubscriptionTypeListParams = SubscriptionTypesAPI.SubscriptionTypeListParams; +} diff --git a/src/resources/tags.ts b/src/resources/tags.ts new file mode 100644 index 00000000..69f82012 --- /dev/null +++ b/src/resources/tags.ts @@ -0,0 +1,414 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as TagsAPI from './tags'; +import * as Shared from './shared'; + +export class Tags extends APIResource { + /** + * You can fetch the details of tags that are on the workspace by their id. This + * will return a tag object. + */ + retrieve( + id: string, + params?: TagRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: TagRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/tags/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch a list of all tags for a given workspace. + */ + list(params?: TagListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: TagListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/tags', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can delete the details of tags that are on the workspace by passing in the + * id. + */ + delete(id: string, params?: TagDeleteParams, options?: Core.RequestOptions): Core.APIPromise; + delete(id: string, options?: Core.RequestOptions): Core.APIPromise; + delete( + id: string, + params: TagDeleteParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.delete(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.delete(`/tags/${id}`, { + ...options, + headers: { + Accept: '*/*', + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + createOrUpdate( + params: TagCreateOrUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/tags', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface TagRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TagListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TagDeleteParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 type TagCreateOrUpdateParams = + | TagCreateOrUpdateParams.CreateOrUpdateTagRequest + | TagCreateOrUpdateParams.TagCompanyRequest + | TagCreateOrUpdateParams.UntagCompanyRequest + | TagCreateOrUpdateParams.TagMultipleUsersRequest; + +export namespace TagCreateOrUpdateParams { + export interface CreateOrUpdateTagRequest { + /** + * Body param: 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; + + /** + * Body param: The id of tag to updates. + */ + id?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TagCompanyRequest { + /** + * Body param: The id or company_id of the company can be passed as input + * parameters. + */ + companies: Array; + + /** + * Body param: The name of the tag, which will be created if not found. + */ + name: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace TagCompanyRequest { + export interface Company { + /** + * The Intercom defined id representing the company. + */ + id?: string; + + /** + * The company id you have defined for the company. + */ + company_id?: string; + } + } + + export interface UntagCompanyRequest { + /** + * Body param: The id or company_id of the company can be passed as input + * parameters. + */ + companies: Array; + + /** + * Body param: The name of the tag which will be untagged from the company + */ + name: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace UntagCompanyRequest { + export interface Company { + /** + * 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; + } + } + + export interface TagMultipleUsersRequest { + /** + * Body param: The name of the tag, which will be created if not found. + */ + name: string; + + /** + * Body param: + */ + users: Array; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace TagMultipleUsersRequest { + export interface User { + /** + * The Intercom defined id representing the user. + */ + id?: string; + } + } +} + +export namespace Tags { + export import TagRetrieveParams = TagsAPI.TagRetrieveParams; + export import TagListParams = TagsAPI.TagListParams; + export import TagDeleteParams = TagsAPI.TagDeleteParams; + export import TagCreateOrUpdateParams = TagsAPI.TagCreateOrUpdateParams; +} diff --git a/src/resources/teams.ts b/src/resources/teams.ts new file mode 100644 index 00000000..8ee2275a --- /dev/null +++ b/src/resources/teams.ts @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import { isRequestOptions } from '../core'; +import * as Core from '../core'; +import * as TeamsAPI from './teams'; + +export class Teams extends APIResource { + /** + * You can fetch the details of a single team, containing an array of admins that + * belong to this team. + */ + retrieve(id: string, params?: TeamRetrieveParams, options?: Core.RequestOptions): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: TeamRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/teams/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * This will return a list of team objects for the App. + */ + list(params?: TeamListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: TeamListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/teams', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * Teams are groups of admins in Intercom. + */ +export interface Team { + /** + * The id of the team + */ + id?: string; + + /** + * The list of admin IDs that are a part of the team. + */ + admin_ids?: Array; + + /** + * Admin priority levels for the team + */ + admin_priority_level?: Team.AdminPriorityLevel | null; + + /** + * The name of the team + */ + name?: string; + + /** + * Value is always "team" + */ + type?: string; +} + +export namespace Team { + /** + * Admin priority levels for the team + */ + export interface AdminPriorityLevel { + /** + * The primary admin ids for the team + */ + primary_admin_ids?: Array | null; + + /** + * The secondary admin ids for the team + */ + secondary_admin_ids?: Array | null; + } +} + +/** + * This will return a list of team objects for the App. + */ +export interface TeamList { + /** + * A list of team objects + */ + teams?: Array; + + /** + * The type of the object + */ + type?: 'team.list'; +} + +export interface TeamRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TeamListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace Teams { + export import Team = TeamsAPI.Team; + export import TeamList = TeamsAPI.TeamList; + export import TeamRetrieveParams = TeamsAPI.TeamRetrieveParams; + export import TeamListParams = TeamsAPI.TeamListParams; +} diff --git a/src/resources/ticket-types/attributes.ts b/src/resources/ticket-types/attributes.ts new file mode 100644 index 00000000..e86007bd --- /dev/null +++ b/src/resources/ticket-types/attributes.ts @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as AttributesAPI from './attributes'; +import * as Shared from '../shared'; + +export class Attributes extends APIResource { + /** + * You can create a new attribute for a ticket type. + */ + create( + ticketTypeId: string, + params: AttributeCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/ticket_types/${ticketTypeId}/attributes`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update an existing attribute for a ticket type. + */ + update( + ticketTypeId: string, + id: string, + params?: AttributeUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update( + ticketTypeId: string, + id: string, + options?: Core.RequestOptions, + ): Core.APIPromise; + update( + ticketTypeId: string, + id: string, + params: AttributeUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(ticketTypeId, id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/ticket_types/${ticketTypeId}/attributes/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface AttributeCreateParams { + /** + * Body param: The data type of the attribute + */ + data_type: 'string' | 'list' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'files'; + + /** + * Body param: The description of the attribute presented to the teammate or + * contact + */ + description: string; + + /** + * Body param: The name of the ticket type attribute + */ + name: string; + + /** + * Body param: Whether the attribute allows multiple files to be attached to it + * (only applicable to file attributes) + */ + allow_multiple_values?: boolean; + + /** + * Body param: A comma delimited list of items for the attribute value (only + * applicable to list attributes) + */ + list_items?: string; + + /** + * Body param: Whether the attribute allows multiple lines of text (only applicable + * to string attributes) + */ + multiline?: boolean; + + /** + * Body param: Whether the attribute is required to be filled in when teammates are + * creating the ticket in Inbox. + */ + required_to_create?: boolean; + + /** + * Body param: Whether the attribute is required to be filled in when contacts are + * creating the ticket in Messenger. + */ + required_to_create_for_contacts?: boolean; + + /** + * Body param: Whether the attribute is visible to teammates when creating a ticket + * in Inbox. + */ + visible_on_create?: boolean; + + /** + * Body param: Whether the attribute is visible to contacts when creating a ticket + * in Messenger. + */ + visible_to_contacts?: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface AttributeUpdateParams { + /** + * Body param: Whether the attribute allows multiple files to be attached to it + * (only applicable to file attributes) + */ + allow_multiple_values?: boolean; + + /** + * Body param: 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; + + /** + * Body param: The description of the attribute presented to the teammate or + * contact + */ + description?: string; + + /** + * Body param: A comma delimited list of items for the attribute value (only + * applicable to list attributes) + */ + list_items?: string; + + /** + * Body param: Whether the attribute allows multiple lines of text (only applicable + * to string attributes) + */ + multiline?: boolean; + + /** + * Body param: The name of the ticket type attribute + */ + name?: string; + + /** + * Body param: Whether the attribute is required to be filled in when teammates are + * creating the ticket in Inbox. + */ + required_to_create?: boolean; + + /** + * Body param: Whether the attribute is required to be filled in when contacts are + * creating the ticket in Messenger. + */ + required_to_create_for_contacts?: boolean; + + /** + * Body param: Whether the attribute is visible to teammates when creating a ticket + * in Inbox. + */ + visible_on_create?: boolean; + + /** + * Body param: Whether the attribute is visible to contacts when creating a ticket + * in Messenger. + */ + visible_to_contacts?: boolean; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Attributes { + export import AttributeCreateParams = AttributesAPI.AttributeCreateParams; + export import AttributeUpdateParams = AttributesAPI.AttributeUpdateParams; +} diff --git a/src/resources/ticket-types/index.ts b/src/resources/ticket-types/index.ts new file mode 100644 index 00000000..bc6ff2cf --- /dev/null +++ b/src/resources/ticket-types/index.ts @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { AttributeCreateParams, AttributeUpdateParams, Attributes } from './attributes'; +export { + TicketType, + TicketTypeList, + TicketTypeCreateParams, + TicketTypeRetrieveParams, + TicketTypeUpdateParams, + TicketTypeListParams, + TicketTypes, +} from './ticket-types'; diff --git a/src/resources/ticket-types/ticket-types.ts b/src/resources/ticket-types/ticket-types.ts new file mode 100644 index 00000000..834460e2 --- /dev/null +++ b/src/resources/ticket-types/ticket-types.ts @@ -0,0 +1,391 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as TicketTypesAPI from './ticket-types'; +import * as Shared from '../shared'; +import * as AttributesAPI from './attributes'; + +export class TicketTypes extends APIResource { + attributes: AttributesAPI.Attributes = new AttributesAPI.Attributes(this._client); + + /** + * 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/) + */ + create(params: TicketTypeCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/ticket_types', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single ticket type. + */ + retrieve( + id: string, + params?: TicketTypeRetrieveParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieve( + id: string, + params: TicketTypeRetrieveParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieve(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/ticket_types/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update a ticket type. + * + * > 📘 Updating a ticket type. + * > + * > For the `icon` propery, use an emoji from + * > [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + */ + update( + id: string, + params?: TicketTypeUpdateParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + update(id: string, options?: Core.RequestOptions): Core.APIPromise; + update( + id: string, + params: TicketTypeUpdateParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.update(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/ticket_types/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can get a list of all ticket types for a workspace. + */ + list(params?: TicketTypeListParams, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; + list( + params: TicketTypeListParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.list({}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get('/ticket_types', { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * A ticket type, used to define the data fields to be captured in a ticket. + */ +export interface TicketType { + /** + * The id representing the ticket type. + */ + id?: string; + + /** + * Whether the ticket type is archived or not. + */ + archived?: boolean; + + /** + * Category of the Ticket Type. + */ + category?: 'Customer' | 'Back-office' | 'Tracker'; + + /** + * The date and time the ticket type was created. + */ + created_at?: number; + + /** + * The description of the ticket type + */ + description?: string; + + /** + * The icon of the ticket type + */ + icon?: string; + + /** + * The name of the ticket type + */ + name?: string; + + /** + * A list of attributes associated with a given ticket type. + */ + ticket_type_attributes?: TicketType.TicketTypeAttributes; + + /** + * String representing the object's type. Always has the value `ticket_type`. + */ + type?: string; + + /** + * The date and time the ticket type was last updated. + */ + updated_at?: number; + + /** + * The id of the workspace that the ticket type belongs to. + */ + workspace_id?: string; +} + +export namespace TicketType { + /** + * A list of attributes associated with a given ticket type. + */ + export interface TicketTypeAttributes { + /** + * A list of ticket type attributes associated with a given ticket type. + */ + ticket_type_attributes?: Array; + + /** + * String representing the object's type. Always has the value + * `ticket_type_attributes.list`. + */ + type?: string; + } +} + +/** + * A list of ticket types associated with a given workspace. + */ +export interface TicketTypeList { + /** + * A list of ticket_types associated with a given workspace. + */ + ticket_types?: Array; + + /** + * String representing the object's type. Always has the value `ticket_type.list`. + */ + type?: string; +} + +export interface TicketTypeCreateParams { + /** + * Body param: The name of the ticket type. + */ + name: string; + + /** + * Body param: Category of the Ticket Type. + */ + category?: 'Customer' | 'Back-office' | 'Tracker'; + + /** + * Body param: The description of the ticket type. + */ + description?: string; + + /** + * Body param: The icon of the ticket type. + */ + icon?: string; + + /** + * Body param: 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; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TicketTypeRetrieveParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TicketTypeUpdateParams { + /** + * Body param: The archived status of the ticket type. + */ + archived?: boolean; + + /** + * Body param: Category of the Ticket Type. + */ + category?: 'Customer' | 'Back-office' | 'Tracker'; + + /** + * Body param: The description of the ticket type. + */ + description?: string; + + /** + * Body param: The icon of the ticket type. + */ + icon?: string; + + /** + * Body param: 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; + + /** + * Body param: The name of the ticket type. + */ + name?: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TicketTypeListParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 namespace TicketTypes { + export import TicketType = TicketTypesAPI.TicketType; + export import TicketTypeList = TicketTypesAPI.TicketTypeList; + export import TicketTypeCreateParams = TicketTypesAPI.TicketTypeCreateParams; + export import TicketTypeRetrieveParams = TicketTypesAPI.TicketTypeRetrieveParams; + export import TicketTypeUpdateParams = TicketTypesAPI.TicketTypeUpdateParams; + export import TicketTypeListParams = TicketTypesAPI.TicketTypeListParams; + export import Attributes = AttributesAPI.Attributes; + export import AttributeCreateParams = AttributesAPI.AttributeCreateParams; + export import AttributeUpdateParams = AttributesAPI.AttributeUpdateParams; +} diff --git a/src/resources/tickets/index.ts b/src/resources/tickets/index.ts new file mode 100644 index 00000000..3eaea6ef --- /dev/null +++ b/src/resources/tickets/index.ts @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { TagCreateParams, TagRemoveParams, Tags } from './tags'; +export { + TicketList, + TicketReply, + TicketCreateParams, + TicketReplyParams, + TicketRetrieveByIDParams, + TicketSearchParams, + TicketUpdateByIDParams, + Tickets, +} from './tickets'; diff --git a/src/resources/tickets/tags.ts b/src/resources/tickets/tags.ts new file mode 100644 index 00000000..41f70afd --- /dev/null +++ b/src/resources/tickets/tags.ts @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import * as Core from '../../core'; +import * as TagsAPI from './tags'; +import * as Shared from '../shared'; + +export class Tags extends APIResource { + /** + * You can tag a specific ticket. This will return a tag object for the tag that + * was added to the ticket. + */ + create( + ticketId: string, + params: TagCreateParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/tickets/${ticketId}/tags`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the + * tag that was removed from the ticket. + */ + remove( + ticketId: string, + id: string, + params: TagRemoveParams, + options?: Core.RequestOptions, + ): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.delete(`/tickets/${ticketId}/tags/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +export interface TagCreateParams { + /** + * Body param: The unique identifier for the tag which is given by Intercom + */ + id: string; + + /** + * Body param: The unique identifier for the admin which is given by Intercom. + */ + admin_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TagRemoveParams { + /** + * Body param: The unique identifier for the admin which is given by Intercom. + */ + admin_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace Tags { + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagRemoveParams = TagsAPI.TagRemoveParams; +} diff --git a/src/resources/tickets/tickets.ts b/src/resources/tickets/tickets.ts new file mode 100644 index 00000000..35c93cc8 --- /dev/null +++ b/src/resources/tickets/tickets.ts @@ -0,0 +1,780 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../resource'; +import { isRequestOptions } from '../../core'; +import * as Core from '../../core'; +import * as TicketsAPI from './tickets'; +import * as Shared from '../shared'; +import * as TagsAPI from './tags'; + +export class Tickets extends APIResource { + tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); + + /** + * You can create a new ticket. + */ + create(params: TicketCreateParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/tickets', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can reply to a ticket with a message from an admin or on behalf of a + * contact, or with a note for admins. + */ + reply(id: string, params: TicketReplyParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post(`/tickets/${id}/reply`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can fetch the details of a single ticket. + */ + retrieveById( + id: string, + params?: TicketRetrieveByIDParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + retrieveById(id: string, options?: Core.RequestOptions): Core.APIPromise; + retrieveById( + id: string, + params: TicketRetrieveByIDParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.retrieveById(id, {}, params); + } + const { 'Intercom-Version': intercomVersion } = params; + return this._client.get(`/tickets/${id}`, { + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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"`). + * + * | 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 | + */ + search(params: TicketSearchParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/tickets/search', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * You can update a ticket. + */ + updateById( + id: string, + params?: TicketUpdateByIDParams, + options?: Core.RequestOptions, + ): Core.APIPromise; + updateById(id: string, options?: Core.RequestOptions): Core.APIPromise; + updateById( + id: string, + params: TicketUpdateByIDParams | Core.RequestOptions = {}, + options?: Core.RequestOptions, + ): Core.APIPromise { + if (isRequestOptions(params)) { + return this.updateById(id, {}, params); + } + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.put(`/tickets/${id}`, { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * Tickets are how you track requests from your users. + */ +export interface TicketList { + /** + * 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. + */ + pages?: Shared.CursorPages | null; + + /** + * The list of ticket objects + */ + tickets?: Array; + + /** + * A count of the total number of objects. + */ + total_count?: number; + + /** + * Always ticket.list + */ + type?: 'ticket.list'; +} + +/** + * A Ticket Part representing a note, comment, or quick_reply on a ticket + */ +export interface TicketReply { + /** + * The id representing the part. + */ + id?: string; + + /** + * A list of attachments for the part. + */ + attachments?: Array; + + /** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ + author?: TicketReply.Author; + + /** + * The message body, which may contain HTML. + */ + body?: string | null; + + /** + * The time the note was created. + */ + created_at?: number; + + /** + * Type of the part + */ + part_type?: 'note' | 'comment' | 'quick_reply'; + + /** + * Whether or not the ticket part has been redacted. + */ + redacted?: boolean; + + /** + * Always ticket_part + */ + type?: 'ticket_part'; + + /** + * The last time the note was updated. + */ + updated_at?: number; +} + +export namespace TicketReply { + /** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ + export interface Author { + /** + * The id of the author + */ + id?: string; + + /** + * The email of the author + */ + email?: string; + + /** + * The name of the author + */ + name?: string | null; + + /** + * The type of the author + */ + type?: 'admin' | 'bot' | 'team' | 'user'; + } +} + +export interface TicketCreateParams { + /** + * Body param: The list of contacts (users or leads) affected by this ticket. + * Currently only one is allowed + */ + contacts: Array; + + /** + * Body param: The ID of the type of ticket you want to create + */ + ticket_type_id: string; + + /** + * Body param: The ID of the company that the ticket is associated with. The ID + * that you set upon company creation. + */ + company_id?: string; + + /** + * Body param: The time the ticket was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Body param: 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`). + */ + ticket_attributes?: Record>; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace TicketCreateParams { + export interface ID { + /** + * The identifier for the contact as given by Intercom. + */ + id: string; + } + + export interface ExternalID { + /** + * The external_id you have defined for the contact who is being added as a + * participant. + */ + external_id: string; + } + + export interface Email { + /** + * The email you have defined for the contact who is being added as a participant. + * If a contact with this email does not exist, one will be created. + */ + email: string; + } +} + +export type TicketReplyParams = + | TicketReplyParams.ContactReplyTicketIntercomUserIDRequest + | TicketReplyParams.ContactReplyTicketUserIDRequest + | TicketReplyParams.ContactReplyTicketEmailRequest + | TicketReplyParams.AdminReplyTicketRequest; + +export namespace TicketReplyParams { + export interface ContactReplyTicketIntercomUserIDRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactReplyTicketUserIDRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface ContactReplyTicketEmailRequest { + /** + * Body param: The text body of the comment. + */ + body: string; + + /** + * Body param: + */ + message_type: 'comment'; + + /** + * Body param: + */ + type: 'user'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface AdminReplyTicketRequest { + /** + * Body param: The id of the admin who is authoring the comment. + */ + admin_id: string; + + /** + * Body param: + */ + message_type: 'comment' | 'note' | 'quick_reply'; + + /** + * Body param: + */ + type: 'admin'; + + /** + * Body param: A list of image URLs that will be added as attachments. You can + * include up to 10 URLs. + */ + attachment_urls?: Array; + + /** + * Body param: The text body of the reply. Notes accept some HTML formatting. Must + * be present for comment and note message types. + */ + body?: string; + + /** + * Body param: The time the reply was created. If not provided, the current time + * will be used. + */ + created_at?: number; + + /** + * Body param: The quick reply options to display. Must be present for quick_reply + * message types. + */ + reply_options?: Array; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace AdminReplyTicketRequest { + export interface ReplyOption { + /** + * 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; + } + } +} + +export interface TicketRetrieveByIDParams { + /** + * Intercom API version.By default, it's equal to the version set in the app + * package. + */ + 'Intercom-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 interface TicketSearchParams { + /** + * Body param: Search using Intercoms Search APIs with a single filter. + */ + query: Shared.SingleFilterSearchRequest | Shared.MultipleFilterSearchRequest; + + /** + * Body param: + */ + pagination?: Shared.StartingAfterPaging | null; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface TicketUpdateByIDParams { + /** + * Body param: + */ + assignment?: TicketUpdateByIDParams.Assignment; + + /** + * Body param: Specify whether the ticket is visible to users. + */ + is_shared?: boolean; + + /** + * Body param: Specify if a ticket is open. Set to false to close a ticket. Closing + * a ticket will also unsnooze it. + */ + open?: boolean; + + /** + * Body param: The time you want the ticket to reopen. + */ + snoozed_until?: number; + + /** + * Body param: The state of the ticket. + */ + state?: 'in_progress' | 'waiting_on_customer' | 'resolved'; + + /** + * Body param: The attributes set on the ticket. + */ + ticket_attributes?: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace TicketUpdateByIDParams { + export interface Assignment { + /** + * The ID of the admin performing the action. + */ + admin_id?: string; + + /** + * The ID of the admin or team to which the ticket is assigned. Set this 0 to + * unassign it. + */ + assignee_id?: string; + } +} + +export namespace Tickets { + export import TicketList = TicketsAPI.TicketList; + export import TicketReply = TicketsAPI.TicketReply; + export import TicketCreateParams = TicketsAPI.TicketCreateParams; + export import TicketReplyParams = TicketsAPI.TicketReplyParams; + export import TicketRetrieveByIDParams = TicketsAPI.TicketRetrieveByIDParams; + export import TicketSearchParams = TicketsAPI.TicketSearchParams; + export import TicketUpdateByIDParams = TicketsAPI.TicketUpdateByIDParams; + export import Tags = TagsAPI.Tags; + export import TagCreateParams = TagsAPI.TagCreateParams; + export import TagRemoveParams = TagsAPI.TagRemoveParams; +} diff --git a/src/resources/visitors.ts b/src/resources/visitors.ts new file mode 100644 index 00000000..b11e91a0 --- /dev/null +++ b/src/resources/visitors.ts @@ -0,0 +1,542 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../resource'; +import * as Core from '../core'; +import * as VisitorsAPI from './visitors'; +import * as Shared from './shared'; + +export class Visitors extends APIResource { + /** + * You can fetch the details of a single visitor. + */ + retrieve(params: VisitorRetrieveParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...query } = params; + return this._client.get('/visitors', { + query, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + update(params: VisitorUpdateParams, options?: Core.RequestOptions): Core.APIPromise { + const { body, 'Intercom-Version': intercomVersion } = params; + return this._client.put('/visitors', { + body: body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } + + /** + * 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. + */ + convert(params: VisitorConvertParams, options?: Core.RequestOptions): Core.APIPromise { + const { 'Intercom-Version': intercomVersion, ...body } = params; + return this._client.post('/visitors/convert', { + body, + ...options, + headers: { + ...(intercomVersion?.toString() != null ? + { 'Intercom-Version': intercomVersion?.toString() } + : undefined), + ...options?.headers, + }, + }); + } +} + +/** + * 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 { + /** + * The Intercom defined id representing the Visitor. + */ + id?: string; + + /** + * Identifies if this visitor is anonymous. + */ + anonymous?: boolean; + + /** + * The id of the app the visitor is associated with. + */ + app_id?: string; + + avatar?: Visitor.Avatar; + + companies?: Visitor.Companies; + + /** + * The time the Visitor was added to Intercom. + */ + created_at?: number; + + /** + * The custom attributes you have set on the Visitor. + */ + custom_attributes?: Record; + + /** + * Identifies if this visitor has do not track enabled. + */ + do_not_track?: boolean | null; + + /** + * The email of the visitor. + */ + email?: string; + + /** + * Identifies if this visitor has had a hard bounce. + */ + has_hard_bounced?: boolean; + + /** + * The time the Lead last recorded making a request. + */ + las_request_at?: number; + + location_data?: Visitor.LocationData; + + /** + * Identifies if this visitor has marked an email as spam. + */ + marked_email_as_spam?: boolean; + + /** + * The name of the visitor. + */ + name?: string | null; + + /** + * The id of the admin that owns the Visitor. + */ + owner_id?: string | null; + + /** + * The phone number of the visitor. + */ + phone?: string | null; + + /** + * The pseudonym of the visitor. + */ + pseudonym?: string | null; + + /** + * The referer of the visitor. + */ + referrer?: string | null; + + /** + * The time the Visitor was added to Intercom. + */ + remote_created_at?: number; + + segments?: Visitor.Segments; + + /** + * The number of sessions the Visitor has had. + */ + session_count?: number; + + /** + * The time the Visitor signed up for your product. + */ + signed_up_at?: number; + + social_profiles?: Visitor.SocialProfiles; + + tags?: Visitor.Tags; + + /** + * Value is 'visitor' + */ + type?: string; + + /** + * Whether the Visitor is unsubscribed from emails. + */ + unsubscribed_from_emails?: boolean; + + /** + * The last time the Visitor was updated. + */ + updated_at?: number; + + /** + * Automatically generated identifier for the Visitor. + */ + user_id?: string; + + /** + * The utm_campaign of the visitor. + */ + utm_campaign?: string | null; + + /** + * The utm_content of the visitor. + */ + utm_content?: string | null; + + /** + * The utm_medium of the visitor. + */ + utm_medium?: string | null; + + /** + * The utm_source of the visitor. + */ + utm_source?: string | null; + + /** + * The utm_term of the visitor. + */ + utm_term?: string | null; +} + +export namespace Visitor { + export interface Avatar { + /** + * This object represents the avatar associated with the visitor. + */ + image_url?: string | null; + + type?: string; + } + + export interface Companies { + companies?: Array; + + /** + * The type of the object + */ + type?: 'company.list'; + } + + export interface LocationData { + /** + * 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; + + type?: string; + } + + export interface Segments { + segments?: Array; + + /** + * The type of the object + */ + type?: 'segment.list'; + } + + export interface SocialProfiles { + social_profiles?: Array; + + /** + * The type of the object + */ + type?: 'social_profile.list'; + } + + export interface Tags { + tags?: Array; + + /** + * The type of the object + */ + type?: 'tag.list'; + } + + export namespace Tags { + export interface Tag { + /** + * The id of the tag. + */ + id?: string; + + /** + * The name of the tag. + */ + name?: string; + + /** + * The type of the object + */ + type?: 'tag'; + } + } +} + +/** + * 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; +} + +export interface VisitorRetrieveParams { + /** + * Query param: The user_id of the Visitor you want to retrieve. + */ + user_id: string; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 type VisitorUpdateParams = VisitorUpdateParams.Variant0 | VisitorUpdateParams.Variant1; + +export namespace VisitorUpdateParams { + export interface Variant0 { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface Variant1 { + /** + * Body param: + */ + body: unknown; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 interface VisitorConvertParams { + /** + * Body param: Represents the role of the Contact model. Accepts `lead` or `user`. + */ + type: string; + + /** + * Body param: The unique identifiers retained after converting or merging. + */ + user: VisitorConvertParams.User; + + /** + * Body param: The unique identifiers to convert a single Visitor. + */ + visitor: VisitorConvertParams.Visitor; + + /** + * Header param: Intercom API version.By default, it's equal to the version set in + * the app package. + */ + 'Intercom-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 namespace VisitorConvertParams { + /** + * The unique identifiers retained after converting or merging. + */ + export interface User { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * The contact's email, retained by default if one is present. + */ + email?: string; + + /** + * A unique identifier for the contact which is given to Intercom, which will be + * represented as external_id. + */ + user_id?: string; + } + + /** + * The unique identifiers to convert a single Visitor. + */ + export interface Visitor { + /** + * The unique identifier for the contact which is given by Intercom. + */ + id?: string; + + /** + * The visitor's email. + */ + email?: string; + + /** + * A unique identifier for the contact which is given to Intercom. + */ + user_id?: string; + } +} + +export namespace Visitors { + export import Visitor = VisitorsAPI.Visitor; + export import VisitorDeletedObject = VisitorsAPI.VisitorDeletedObject; + export import VisitorRetrieveParams = VisitorsAPI.VisitorRetrieveParams; + export import VisitorUpdateParams = VisitorsAPI.VisitorUpdateParams; + export import VisitorConvertParams = VisitorsAPI.VisitorConvertParams; +} diff --git a/src/shims/node.ts b/src/shims/node.ts new file mode 100644 index 00000000..73df5600 --- /dev/null +++ b/src/shims/node.ts @@ -0,0 +1,50 @@ +// @ts-ignore +import * as types from '../_shims/node-types'; +import { setShims } from '../_shims/registry'; +import { getRuntime } from '../_shims/node-runtime'; +setShims(getRuntime()); + +declare module '../_shims/manual-types' { + export namespace manual { + // @ts-ignore + export type Agent = types.Agent; + // @ts-ignore + export import fetch = types.fetch; + // @ts-ignore + export type Request = types.Request; + // @ts-ignore + export type RequestInfo = types.RequestInfo; + // @ts-ignore + export type RequestInit = types.RequestInit; + // @ts-ignore + export type Response = types.Response; + // @ts-ignore + export type ResponseInit = types.ResponseInit; + // @ts-ignore + export type ResponseType = types.ResponseType; + // @ts-ignore + export type BodyInit = types.BodyInit; + // @ts-ignore + export type Headers = types.Headers; + // @ts-ignore + export type HeadersInit = types.HeadersInit; + // @ts-ignore + export type BlobPropertyBag = types.BlobPropertyBag; + // @ts-ignore + export type FilePropertyBag = types.FilePropertyBag; + // @ts-ignore + export type FileFromPathOptions = types.FileFromPathOptions; + // @ts-ignore + export import FormData = types.FormData; + // @ts-ignore + export import File = types.File; + // @ts-ignore + export import Blob = types.Blob; + // @ts-ignore + export type Readable = types.Readable; + // @ts-ignore + export type FsReadStream = types.FsReadStream; + // @ts-ignore + export import ReadableStream = types.ReadableStream; + } +} diff --git a/src/shims/web.ts b/src/shims/web.ts new file mode 100644 index 00000000..f72d7844 --- /dev/null +++ b/src/shims/web.ts @@ -0,0 +1,50 @@ +// @ts-ignore +import * as types from '../_shims/web-types'; +import { setShims } from '../_shims/registry'; +import { getRuntime } from '../_shims/web-runtime'; +setShims(getRuntime({ manuallyImported: true })); + +declare module '../_shims/manual-types' { + export namespace manual { + // @ts-ignore + export type Agent = types.Agent; + // @ts-ignore + export import fetch = types.fetch; + // @ts-ignore + export type Request = types.Request; + // @ts-ignore + export type RequestInfo = types.RequestInfo; + // @ts-ignore + export type RequestInit = types.RequestInit; + // @ts-ignore + export type Response = types.Response; + // @ts-ignore + export type ResponseInit = types.ResponseInit; + // @ts-ignore + export type ResponseType = types.ResponseType; + // @ts-ignore + export type BodyInit = types.BodyInit; + // @ts-ignore + export type Headers = types.Headers; + // @ts-ignore + export type HeadersInit = types.HeadersInit; + // @ts-ignore + export type BlobPropertyBag = types.BlobPropertyBag; + // @ts-ignore + export type FilePropertyBag = types.FilePropertyBag; + // @ts-ignore + export type FileFromPathOptions = types.FileFromPathOptions; + // @ts-ignore + export import FormData = types.FormData; + // @ts-ignore + export import File = types.File; + // @ts-ignore + export import Blob = types.Blob; + // @ts-ignore + export type Readable = types.Readable; + // @ts-ignore + export type FsReadStream = types.FsReadStream; + // @ts-ignore + export import ReadableStream = types.ReadableStream; + } +} diff --git a/src/uploads.ts b/src/uploads.ts new file mode 100644 index 00000000..081827c9 --- /dev/null +++ b/src/uploads.ts @@ -0,0 +1,248 @@ +import { type RequestOptions } from './core'; +import { + FormData, + File, + type Blob, + type FilePropertyBag, + getMultipartRequestOptions, + type FsReadStream, + isFsReadStream, +} from './_shims/index'; +import { MultipartBody } from './_shims/MultipartBody'; +export { fileFromPath } from './_shims/index'; + +type BlobLikePart = string | ArrayBuffer | ArrayBufferView | BlobLike | Uint8Array | DataView; +export type BlobPart = string | ArrayBuffer | ArrayBufferView | Blob | Uint8Array | DataView; + +/** + * Typically, this is a native "File" class. + * + * We provide the {@link toFile} utility to convert a variety of objects + * into the File class. + * + * For convenience, you can also pass a fetch Response, or in Node, + * the result of fs.createReadStream(). + */ +export type Uploadable = FileLike | ResponseLike | FsReadStream; + +/** + * Intended to match web.Blob, node.Blob, node-fetch.Blob, etc. + */ +export interface BlobLike { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) */ + readonly size: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) */ + readonly type: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) */ + text(): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) */ + slice(start?: number, end?: number): BlobLike; + // unfortunately @types/node-fetch@^2.6.4 doesn't type the arrayBuffer method +} + +/** + * Intended to match web.File, node.File, node-fetch.File, etc. + */ +export interface FileLike extends BlobLike { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) */ + readonly lastModified: number; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) */ + readonly name: string; +} + +/** + * Intended to match web.Response, node.Response, node-fetch.Response, etc. + */ +export interface ResponseLike { + url: string; + blob(): Promise; +} + +export const isResponseLike = (value: any): value is ResponseLike => + value != null && + typeof value === 'object' && + typeof value.url === 'string' && + typeof value.blob === 'function'; + +export const isFileLike = (value: any): value is FileLike => + value != null && + typeof value === 'object' && + typeof value.name === 'string' && + typeof value.lastModified === 'number' && + isBlobLike(value); + +/** + * The BlobLike type omits arrayBuffer() because @types/node-fetch@^2.6.4 lacks it; but this check + * adds the arrayBuffer() method type because it is available and used at runtime + */ +export const isBlobLike = (value: any): value is BlobLike & { arrayBuffer(): Promise } => + value != null && + typeof value === 'object' && + typeof value.size === 'number' && + typeof value.type === 'string' && + typeof value.text === 'function' && + typeof value.slice === 'function' && + typeof value.arrayBuffer === 'function'; + +export const isUploadable = (value: any): value is Uploadable => { + return isFileLike(value) || isResponseLike(value) || isFsReadStream(value); +}; + +export type ToFileInput = Uploadable | Exclude | AsyncIterable; + +/** + * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats + * @param value the raw content of the file. Can be an {@link Uploadable}, {@link BlobLikePart}, or {@link AsyncIterable} of {@link BlobLikePart}s + * @param {string=} name the name of the file. If omitted, toFile will try to determine a file name from bits if possible + * @param {Object=} options additional properties + * @param {string=} options.type the MIME type of the content + * @param {number=} options.lastModified the last modified timestamp + * @returns a {@link File} with the given properties + */ +export async function toFile( + value: ToFileInput | PromiseLike, + name?: string | null | undefined, + options?: FilePropertyBag | undefined, +): Promise { + // If it's a promise, resolve it. + value = await value; + + // Use the file's options if there isn't one provided + options ??= isFileLike(value) ? { lastModified: value.lastModified, type: value.type } : {}; + + if (isResponseLike(value)) { + const blob = await value.blob(); + name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file'; + + return new File([blob as any], name, options); + } + + const bits = await getBytes(value); + + name ||= getName(value) ?? 'unknown_file'; + + if (!options.type) { + const type = (bits[0] as any)?.type; + if (typeof type === 'string') { + options = { ...options, type }; + } + } + + return new File(bits, name, options); +} + +async function getBytes(value: ToFileInput): Promise> { + let parts: Array = []; + if ( + typeof value === 'string' || + ArrayBuffer.isView(value) || // includes Uint8Array, Buffer, etc. + value instanceof ArrayBuffer + ) { + parts.push(value); + } else if (isBlobLike(value)) { + parts.push(await value.arrayBuffer()); + } else if ( + isAsyncIterableIterator(value) // includes Readable, ReadableStream, etc. + ) { + for await (const chunk of value) { + parts.push(chunk as BlobPart); // TODO, consider validating? + } + } else { + throw new Error( + `Unexpected data type: ${typeof value}; constructor: ${value?.constructor + ?.name}; props: ${propsForError(value)}`, + ); + } + + return parts; +} + +function propsForError(value: any): string { + const props = Object.getOwnPropertyNames(value); + return `[${props.map((p) => `"${p}"`).join(', ')}]`; +} + +function getName(value: any): string | undefined { + return ( + getStringFromMaybeBuffer(value.name) || + getStringFromMaybeBuffer(value.filename) || + // For fs.ReadStream + getStringFromMaybeBuffer(value.path)?.split(/[\\/]/).pop() + ); +} + +const getStringFromMaybeBuffer = (x: string | Buffer | unknown): string | undefined => { + if (typeof x === 'string') return x; + if (typeof Buffer !== 'undefined' && x instanceof Buffer) return String(x); + return undefined; +}; + +const isAsyncIterableIterator = (value: any): value is AsyncIterableIterator => + value != null && typeof value === 'object' && typeof value[Symbol.asyncIterator] === 'function'; + +export const isMultipartBody = (body: any): body is MultipartBody => + body && typeof body === 'object' && body.body && body[Symbol.toStringTag] === 'MultipartBody'; + +/** + * Returns a multipart/form-data request if any part of the given request body contains a File / Blob value. + * Otherwise returns the request as is. + */ +export const maybeMultipartFormRequestOptions = async >( + opts: RequestOptions, +): Promise> => { + if (!hasUploadableValue(opts.body)) return opts; + + const form = await createForm(opts.body); + return getMultipartRequestOptions(form, opts); +}; + +export const multipartFormRequestOptions = async >( + opts: RequestOptions, +): Promise> => { + const form = await createForm(opts.body); + return getMultipartRequestOptions(form, opts); +}; + +export const createForm = async >(body: T | undefined): Promise => { + const form = new FormData(); + await Promise.all(Object.entries(body || {}).map(([key, value]) => addFormValue(form, key, value))); + return form; +}; + +const hasUploadableValue = (value: unknown): boolean => { + if (isUploadable(value)) return true; + if (Array.isArray(value)) return value.some(hasUploadableValue); + if (value && typeof value === 'object') { + for (const k in value) { + if (hasUploadableValue((value as any)[k])) return true; + } + } + return false; +}; + +const addFormValue = async (form: FormData, key: string, value: unknown): Promise => { + if (value === undefined) return; + if (value == null) { + throw new TypeError( + `Received null for "${key}"; to pass null in FormData, you must use the string 'null'`, + ); + } + + // TODO: make nested formats configurable + if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { + form.append(key, String(value)); + } else if (isUploadable(value)) { + const file = await toFile(value); + form.append(key, file as File); + } else if (Array.isArray(value)) { + await Promise.all(value.map((entry) => addFormValue(form, key + '[]', entry))); + } else if (typeof value === 'object') { + await Promise.all( + Object.entries(value).map(([name, prop]) => addFormValue(form, `${key}[${name}]`, prop)), + ); + } else { + throw new TypeError( + `Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`, + ); + } +}; diff --git a/src/version.ts b/src/version.ts index 948f7433..b5df0ff3 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "7.0.3"; +export const VERSION = '6.0.0-beta.3'; // x-release-please-version diff --git a/tests/api-resources/admins/activity-logs.test.ts b/tests/api-resources/admins/activity-logs.test.ts new file mode 100644 index 00000000..3a4c4a36 --- /dev/null +++ b/tests/api-resources/admins/activity-logs.test.ts @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource activityLogs', () => { + test('list: only required params', async () => { + const responsePromise = client.admins.activityLogs.list({ created_at_after: 'created_at_after' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: required and optional params', async () => { + const response = await client.admins.activityLogs.list({ + created_at_after: 'created_at_after', + created_at_before: 'created_at_before', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/admins/admins.test.ts b/tests/api-resources/admins/admins.test.ts new file mode 100644 index 00000000..43e3105a --- /dev/null +++ b/tests/api-resources/admins/admins.test.ts @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource admins', () => { + test('retrieve', async () => { + const responsePromise = client.admins.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.admins.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.admins.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.admins.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.admins.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.admins.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('setAway: only required params', async () => { + const responsePromise = client.admins.setAway(0, { away_mode_enabled: true, away_mode_reassign: true }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('setAway: required and optional params', async () => { + const response = await client.admins.setAway(0, { + away_mode_enabled: true, + away_mode_reassign: true, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/articles.test.ts b/tests/api-resources/articles.test.ts new file mode 100644 index 00000000..75a4dca2 --- /dev/null +++ b/tests/api-resources/articles.test.ts @@ -0,0 +1,996 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource articles', () => { + test('create: only required params', async () => { + const responsePromise = client.articles.create({ author_id: 991268363, title: 'Thanks for everything' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.articles.create({ + author_id: 991268363, + title: 'Thanks for everything', + body: 'Body of the Article', + description: 'Description of the Article', + parent_id: 290, + parent_type: 'collection', + state: 'published', + translated_content: { + type: 'article_translated_content', + ar: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + bg: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + bs: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ca: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + cs: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + da: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + de: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + el: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + en: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + es: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + et: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + fi: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + fr: { + type: 'article_content', + title: 'Merci pour tout', + description: "Description de l'article", + body: "Corps de l'article", + author_id: 991268363, + state: 'published', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + he: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + hr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + hu: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + id: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + it: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ja: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ko: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + lt: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + lv: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + mn: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + nb: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + nl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + pl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + pt: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ro: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ru: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sv: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + tr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + vi: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'pt-BR': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'zh-CN': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'zh-TW': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + }, + 'Intercom-Version': '2.11', + }); + }); + + test('retrieve', async () => { + const responsePromise = client.articles.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.articles.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.articles.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.articles.update(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.articles.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.articles.update( + 123, + { + author_id: 1295, + body: '

New gifts in store for the jolly season

', + description: 'Description of the Article', + parent_id: '18', + parent_type: 'collection', + state: 'draft', + title: 'Christmas is here!', + translated_content: { + type: 'article_translated_content', + ar: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + bg: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + bs: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ca: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + cs: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + da: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + de: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + el: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + en: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + es: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + et: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + fi: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + fr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + he: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + hr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + hu: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + id: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + it: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ja: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ko: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + lt: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + lv: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + mn: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + nb: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + nl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + pl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + pt: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ro: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + ru: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sl: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + sv: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + tr: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + vi: { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'pt-BR': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'zh-CN': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + 'zh-TW': { + type: 'article_content', + title: 'How to create a new article', + description: 'This article will show you how to create a new article.', + body: 'This is the body of the article.', + author_id: 0, + state: 'draft', + created_at: 1663597223, + updated_at: 1663597260, + url: 'http://intercom.test/help/en/articles/3-default-language', + }, + }, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.articles.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.articles.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.articles.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('remove', async () => { + const responsePromise = client.articles.remove(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('remove: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.articles.remove(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('remove: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.articles.remove(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('search', async () => { + const responsePromise = client.articles.search(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('search: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.articles.search({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('search: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.articles.search( + { help_center_id: 0, highlight: true, phrase: 'phrase', state: 'state', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/companies/companies.test.ts b/tests/api-resources/companies/companies.test.ts new file mode 100644 index 00000000..4ba4a25a --- /dev/null +++ b/tests/api-resources/companies/companies.test.ts @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource companies', () => { + test('create', async () => { + const responsePromise = client.companies.create(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.companies.create({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.create( + { + company_id: 'company_remote_id', + custom_attributes: { paid_subscriber: 'string', monthly_spend: 'string', team_mates: 'string' }, + industry: 'Manufacturing', + monthly_spend: 1000, + name: 'my company', + plan: 'Enterprise', + remote_created_at: 1374138000, + size: 0, + website: 'https://www.example.com', + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve', async () => { + const responsePromise = client.companies.retrieve('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.retrieve('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.retrieve( + '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.companies.update('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.update('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.update( + '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.companies.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.companies.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.list( + { order: 'order', page: 0, per_page: 0, 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.companies.delete('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.delete('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.delete( + '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieveList', async () => { + const responsePromise = client.companies.retrieveList(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieveList: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.companies.retrieveList({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieveList: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.retrieveList( + { + company_id: 'company_id', + name: 'name', + page: 0, + per_page: 0, + segment_id: 'segment_id', + tag_id: 'tag_id', + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('scroll', async () => { + const responsePromise = client.companies.scroll(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('scroll: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.companies.scroll({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('scroll: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.scroll( + { scroll_param: 'scroll_param', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/companies/contacts.test.ts b/tests/api-resources/companies/contacts.test.ts new file mode 100644 index 00000000..ddb61d76 --- /dev/null +++ b/tests/api-resources/companies/contacts.test.ts @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource contacts', () => { + test('list', async () => { + const responsePromise = client.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.contacts.list( + '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/companies/segments.test.ts b/tests/api-resources/companies/segments.test.ts new file mode 100644 index 00000000..611aeea7 --- /dev/null +++ b/tests/api-resources/companies/segments.test.ts @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource segments', () => { + test('list', async () => { + const responsePromise = client.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.companies.segments.list( + '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/companies.test.ts b/tests/api-resources/contacts/companies.test.ts new file mode 100644 index 00000000..6e986d1a --- /dev/null +++ b/tests/api-resources/contacts/companies.test.ts @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource companies', () => { + test('create: only required params', async () => { + const responsePromise = client.contacts.companies.create('contact_id', { + company_id: '6657add46abd0167d9419cd2', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.contacts.companies.create('contact_id', { + company_id: '6657add46abd0167d9419cd2', + 'Intercom-Version': '2.11', + }); + }); + + test('list', async () => { + const responsePromise = client.contacts.companies.list('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.companies.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.companies.list( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.contacts.companies.delete( + '58a430d35458202d41b1e65b', + '58a430d35458202d41b1e65b', + ); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.companies.delete('58a430d35458202d41b1e65b', '58a430d35458202d41b1e65b', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.companies.delete( + '58a430d35458202d41b1e65b', + '58a430d35458202d41b1e65b', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/contacts.test.ts b/tests/api-resources/contacts/contacts.test.ts new file mode 100644 index 00000000..382d5007 --- /dev/null +++ b/tests/api-resources/contacts/contacts.test.ts @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource contacts', () => { + test('create: only required params', async () => { + const responsePromise = client.contacts.create({ body: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.contacts.create({ body: {}, 'Intercom-Version': '2.11' }); + }); + + test('retrieve', async () => { + const responsePromise = client.contacts.retrieve('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.retrieve('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.retrieve( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.contacts.update('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.update('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.update( + '63a07ddf05a32042dffac965', + { + avatar: 'https://www.example.com/avatar_image.jpg', + custom_attributes: {}, + email: 'jdoe@example.com', + external_id: 'external_id', + last_seen_at: 1571672154, + name: 'John Doe', + owner_id: 123, + phone: '+353871234567', + role: 'role', + signed_up_at: 1571672154, + unsubscribed_from_emails: true, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.contacts.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.contacts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.contacts.delete('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.contacts.delete('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.delete('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('archive', async () => { + const responsePromise = client.contacts.archive('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('archive: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.archive('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('archive: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.archive( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('merge', async () => { + const responsePromise = client.contacts.merge(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('merge: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.contacts.merge({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('merge: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.merge( + { from: '6657adf76abd0167d9419d1d', into: '6657adf76abd0167d9419d1e', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('search: only required params', async () => { + const responsePromise = client.contacts.search({ query: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('search: required and optional params', async () => { + const response = await client.contacts.search({ + query: { field: 'created_at', operator: '=', value: 'value' }, + pagination: { per_page: 5, starting_after: 'your-cursor-from-response' }, + 'Intercom-Version': '2.11', + }); + }); + + test('unarchive', async () => { + const responsePromise = client.contacts.unarchive('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('unarchive: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.unarchive('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('unarchive: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.unarchive( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/notes.test.ts b/tests/api-resources/contacts/notes.test.ts new file mode 100644 index 00000000..396c93bf --- /dev/null +++ b/tests/api-resources/contacts/notes.test.ts @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource notes', () => { + test('create: only required params', async () => { + const responsePromise = client.contacts.notes.create(0, { body: 'Hello' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.contacts.notes.create(0, { + body: 'Hello', + admin_id: 'admin_id', + contact_id: '6657adde6abd0167d9419d00', + 'Intercom-Version': '2.11', + }); + }); + + test('list', async () => { + const responsePromise = client.contacts.notes.list(0); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.contacts.notes.list(0, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.notes.list(0, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/segments.test.ts b/tests/api-resources/contacts/segments.test.ts new file mode 100644 index 00000000..a295ee8d --- /dev/null +++ b/tests/api-resources/contacts/segments.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource segments', () => { + test('list', async () => { + const responsePromise = client.contacts.segments.list('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.segments.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.segments.list( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/subscriptions.test.ts b/tests/api-resources/contacts/subscriptions.test.ts new file mode 100644 index 00000000..32b84f7b --- /dev/null +++ b/tests/api-resources/contacts/subscriptions.test.ts @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource subscriptions', () => { + test('create: only required params', async () => { + const responsePromise = client.contacts.subscriptions.create('63a07ddf05a32042dffac965', { + id: 'id', + consent_type: 'opt_in', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.contacts.subscriptions.create('63a07ddf05a32042dffac965', { + id: 'id', + consent_type: 'opt_in', + 'Intercom-Version': '2.11', + }); + }); + + test('list', async () => { + const responsePromise = client.contacts.subscriptions.list('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.subscriptions.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.subscriptions.list( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.subscriptions.delete( + '63a07ddf05a32042dffac965', + '37846', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/contacts/tags.test.ts b/tests/api-resources/contacts/tags.test.ts new file mode 100644 index 00000000..ce7e2d51 --- /dev/null +++ b/tests/api-resources/contacts/tags.test.ts @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource tags', () => { + test('create: only required params', async () => { + const responsePromise = client.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.contacts.tags.create('63a07ddf05a32042dffac965', { + id: 'id', + 'Intercom-Version': '2.11', + }); + }); + + test('list', async () => { + const responsePromise = client.contacts.tags.list('63a07ddf05a32042dffac965'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.tags.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.tags.list( + '63a07ddf05a32042dffac965', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907', { + path: '/_stainless_unknown_path', + }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.contacts.tags.delete( + '63a07ddf05a32042dffac965', + '7522907', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/conversations/conversations.test.ts b/tests/api-resources/conversations/conversations.test.ts new file mode 100644 index 00000000..5668bf42 --- /dev/null +++ b/tests/api-resources/conversations/conversations.test.ts @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource conversations', () => { + test('create: only required params', async () => { + const responsePromise = client.conversations.create({ + body: 'Hello there', + from: { type: 'user', id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }, + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.conversations.create({ + body: 'Hello there', + from: { type: 'user', id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }, + 'Intercom-Version': '2.11', + }); + }); + + test('retrieve', async () => { + const responsePromise = client.conversations.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.conversations.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.retrieve( + 123, + { display_as: 'display_as', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.conversations.update(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.conversations.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.update( + 123, + { + display_as: 'display_as', + custom_attributes: { issue_type: 'Billing', priority: 'High' }, + read: true, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.conversations.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.conversations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.list( + { per_page: 0, starting_after: 'starting_after', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('convert: only required params', async () => { + const responsePromise = client.conversations.convert(123, { ticket_type_id: '120' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('convert: required and optional params', async () => { + const response = await client.conversations.convert(123, { + ticket_type_id: '120', + attributes: { _default_title_: 'Found a bug', _default_description_: 'The button is not working' }, + 'Intercom-Version': '2.11', + }); + }); + + test('redact: only required params', async () => { + const responsePromise = client.conversations.redact({ + conversation_id: '19894788788', + conversation_part_id: '19381789428', + type: 'conversation_part', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('redact: required and optional params', async () => { + const response = await client.conversations.redact({ + conversation_id: '19894788788', + conversation_part_id: '19381789428', + type: 'conversation_part', + 'Intercom-Version': '2.11', + }); + }); + + test('search: only required params', async () => { + const responsePromise = client.conversations.search({ query: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('search: required and optional params', async () => { + const response = await client.conversations.search({ + query: { field: 'created_at', operator: '=', value: 'value' }, + pagination: { per_page: 5, starting_after: 'your-cursor-from-response' }, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/conversations/customers.test.ts b/tests/api-resources/conversations/customers.test.ts new file mode 100644 index 00000000..0fe51393 --- /dev/null +++ b/tests/api-resources/conversations/customers.test.ts @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource customers', () => { + test('create', async () => { + const responsePromise = client.conversations.customers.create('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.customers.create('123', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.customers.create( + '123', + { + admin_id: 'admin_id', + customer: { + intercom_user_id: '6657ae626abd0167d9419d6f', + customer: { intercom_user_id: '6329bd9ffe4e2e91dac76188' }, + }, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: only required params', async () => { + const responsePromise = client.conversations.customers.delete('123', '123', { admin_id: 'admin_id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: required and optional params', async () => { + const response = await client.conversations.customers.delete('123', '123', { + admin_id: 'admin_id', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/conversations/parts.test.ts b/tests/api-resources/conversations/parts.test.ts new file mode 100644 index 00000000..e6a93f15 --- /dev/null +++ b/tests/api-resources/conversations/parts.test.ts @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource parts', () => { + test('create: only required params', async () => { + const responsePromise = client.conversations.parts.create('123', { + admin_id: '12345', + message_type: 'close', + type: 'admin', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.conversations.parts.create('123', { + admin_id: '12345', + message_type: 'close', + type: 'admin', + body: ' This conversation is now closed!', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/conversations/reply.test.ts b/tests/api-resources/conversations/reply.test.ts new file mode 100644 index 00000000..70f7c637 --- /dev/null +++ b/tests/api-resources/conversations/reply.test.ts @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource reply', () => { + test('create: only required params', async () => { + const responsePromise = client.conversations.reply.create('123 or "last"', { + body: 'body', + message_type: 'comment', + type: 'user', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.conversations.reply.create('123 or "last"', { + body: 'body', + message_type: 'comment', + type: 'user', + attachment_urls: ['https://example.com', 'https://example.com', 'https://example.com'], + created_at: 1590000000, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/conversations/run-assignment-rules.test.ts b/tests/api-resources/conversations/run-assignment-rules.test.ts new file mode 100644 index 00000000..e4cdfecb --- /dev/null +++ b/tests/api-resources/conversations/run-assignment-rules.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource runAssignmentRules', () => { + test('create', async () => { + const responsePromise = client.conversations.runAssignmentRules.create('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.runAssignmentRules.create('123', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('create: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.conversations.runAssignmentRules.create( + '123', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/conversations/tags.test.ts b/tests/api-resources/conversations/tags.test.ts new file mode 100644 index 00000000..6b462288 --- /dev/null +++ b/tests/api-resources/conversations/tags.test.ts @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource tags', () => { + test('create: only required params', async () => { + const responsePromise = client.conversations.tags.create('64619700005694', { + id: 'id', + admin_id: 'admin_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.conversations.tags.create('64619700005694', { + id: 'id', + admin_id: 'admin_id', + 'Intercom-Version': '2.11', + }); + }); + + test('delete: only required params', async () => { + const responsePromise = client.conversations.tags.delete('64619700005694', '7522907', { + admin_id: 'admin_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: required and optional params', async () => { + const response = await client.conversations.tags.delete('64619700005694', '7522907', { + admin_id: 'admin_id', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/data-attributes.test.ts b/tests/api-resources/data-attributes.test.ts new file mode 100644 index 00000000..5cba46a5 --- /dev/null +++ b/tests/api-resources/data-attributes.test.ts @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource dataAttributes', () => { + test('create: only required params', async () => { + const responsePromise = client.dataAttributes.create({ + data_type: 'string', + model: 'company', + name: 'Mithril Shirt', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.dataAttributes.create({ + data_type: 'string', + model: 'company', + name: 'Mithril Shirt', + description: 'My Data Attribute Description', + messenger_writable: false, + options: ['option1', 'option2'], + 'Intercom-Version': '2.11', + }); + }); + + test('update', async () => { + const responsePromise = client.dataAttributes.update(1); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.dataAttributes.update(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.dataAttributes.update( + 1, + { + archived: false, + description: 'Just a plain old ring', + messenger_writable: false, + options: ['string', 'string'], + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.dataAttributes.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.dataAttributes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.dataAttributes.list( + { include_archived: true, model: 'contact', 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/data-events.test.ts b/tests/api-resources/data-events.test.ts new file mode 100644 index 00000000..2c347bce --- /dev/null +++ b/tests/api-resources/data-events.test.ts @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource dataEvents', () => { + test('create: only required params', async () => { + const responsePromise = client.dataEvents.create({ body: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.dataEvents.create({ body: {}, 'Intercom-Version': '2.11' }); + }); + + test('list: only required params', async () => { + const responsePromise = client.dataEvents.list({ filter: { user_id: 'user_id' }, type: 'type' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: required and optional params', async () => { + const response = await client.dataEvents.list({ + filter: { user_id: 'user_id' }, + type: 'type', + summary: true, + 'Intercom-Version': '2.11', + }); + }); + + test('summaries', async () => { + const responsePromise = client.dataEvents.summaries(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('summaries: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.dataEvents.summaries({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('summaries: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.dataEvents.summaries( + { + event_summaries: { event_name: 'invited-friend', count: 1, first: 1671028894, last: 1671028894 }, + user_id: '314159', + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/data-exports.test.ts b/tests/api-resources/data-exports.test.ts new file mode 100644 index 00000000..0c126881 --- /dev/null +++ b/tests/api-resources/data-exports.test.ts @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource dataExports', () => { + test('contentData: only required params', async () => { + const responsePromise = client.dataExports.contentData({ + created_at_after: 1717004390, + created_at_before: 1717022390, + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('contentData: required and optional params', async () => { + const response = await client.dataExports.contentData({ + created_at_after: 1717004390, + created_at_before: 1717022390, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/download/content/data.test.ts b/tests/api-resources/download/content/data.test.ts new file mode 100644 index 00000000..bab30d1a --- /dev/null +++ b/tests/api-resources/download/content/data.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource data', () => { + test('retrieve', async () => { + const responsePromise = client.download.content.data.retrieve('job_identifier'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.download.content.data.retrieve('job_identifier', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.download.content.data.retrieve( + 'job_identifier', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/export/content/data.test.ts b/tests/api-resources/export/content/data.test.ts new file mode 100644 index 00000000..2c8fbedd --- /dev/null +++ b/tests/api-resources/export/content/data.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource data', () => { + test('retrieve', async () => { + const responsePromise = client.export.content.data.retrieve('job_identifier'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.export.content.data.retrieve('job_identifier', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.export.content.data.retrieve( + 'job_identifier', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/export/export.test.ts b/tests/api-resources/export/export.test.ts new file mode 100644 index 00000000..1d684164 --- /dev/null +++ b/tests/api-resources/export/export.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource export', () => { + test('cancel', async () => { + const responsePromise = client.export.cancel('job_identifier'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('cancel: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.export.cancel('job_identifier', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('cancel: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.export.cancel( + 'job_identifier', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/help-center/collections.test.ts b/tests/api-resources/help-center/collections.test.ts new file mode 100644 index 00000000..b481ceb5 --- /dev/null +++ b/tests/api-resources/help-center/collections.test.ts @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource collections', () => { + test('create: only required params', async () => { + const responsePromise = client.helpCenter.collections.create({ name: 'Thanks for everything' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.helpCenter.collections.create({ + name: 'Thanks for everything', + description: 'English description', + help_center_id: 0, + parent_id: '6871118', + translated_content: { + type: 'group_translated_content', + ar: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + bg: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + bs: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ca: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + cs: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + da: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + de: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + el: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + en: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + es: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + et: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + fi: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + fr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + he: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + hr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + hu: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + id: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + it: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ja: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ko: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + lt: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + lv: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + mn: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + nb: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + nl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + pl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + pt: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ro: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ru: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sv: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + tr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + vi: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + 'pt-BR': { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + 'zh-CN': { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + 'zh-TW': { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + }, + 'Intercom-Version': '2.11', + }); + }); + + test('retrieve', async () => { + const responsePromise = client.helpCenter.collections.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.retrieve(123, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.retrieve( + 123, + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.helpCenter.collections.update(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.update(123, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.update( + 123, + { + description: 'English description', + name: 'Update collection name', + parent_id: '6871118', + translated_content: { + type: 'group_translated_content', + ar: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + bg: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + bs: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ca: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + cs: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + da: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + de: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + el: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + en: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + es: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + et: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + fi: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + fr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + he: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + hr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + hu: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + id: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + it: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ja: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ko: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + lt: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + lv: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + mn: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + nb: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + nl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + pl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + pt: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ro: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + ru: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sl: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + sv: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + tr: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + vi: { type: 'group_content', name: 'Collection name', description: ' Collection description' }, + 'pt-BR': { + type: 'group_content', + name: 'Collection name', + description: ' Collection description', + }, + 'zh-CN': { + type: 'group_content', + name: 'Collection name', + description: ' Collection description', + }, + 'zh-TW': { + type: 'group_content', + name: 'Collection name', + description: ' Collection description', + }, + }, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.helpCenter.collections.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.helpCenter.collections.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.list( + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.helpCenter.collections.delete(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.delete(123, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.collections.delete( + 123, + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/help-center/help-centers.test.ts b/tests/api-resources/help-center/help-centers.test.ts new file mode 100644 index 00000000..9f3abe74 --- /dev/null +++ b/tests/api-resources/help-center/help-centers.test.ts @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource helpCenters', () => { + test('retrieve', async () => { + const responsePromise = client.helpCenter.helpCenters.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.helpCenters.retrieve(123, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.helpCenters.retrieve( + 123, + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.helpCenter.helpCenters.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.helpCenter.helpCenters.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.helpCenter.helpCenters.list( + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/me.test.ts b/tests/api-resources/me.test.ts new file mode 100644 index 00000000..d4ad2666 --- /dev/null +++ b/tests/api-resources/me.test.ts @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource me', () => { + test('retrieve', async () => { + const responsePromise = client.me.retrieve(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.me.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.me.retrieve({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/messages.test.ts b/tests/api-resources/messages.test.ts new file mode 100644 index 00000000..afb89e9b --- /dev/null +++ b/tests/api-resources/messages.test.ts @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource messages', () => { + test('create: only required params', async () => { + const responsePromise = client.messages.create({ body: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.messages.create({ body: {}, 'Intercom-Version': '2.11' }); + }); +}); diff --git a/tests/api-resources/news/news-items.test.ts b/tests/api-resources/news/news-items.test.ts new file mode 100644 index 00000000..f7275466 --- /dev/null +++ b/tests/api-resources/news/news-items.test.ts @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource newsItems', () => { + test('create: only required params', async () => { + const responsePromise = client.news.newsItems.create({ + sender_id: 991268690, + title: 'Halloween is here!', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.news.newsItems.create({ + sender_id: 991268690, + title: 'Halloween is here!', + body: '

New costumes in store for this spooky season

', + deliver_silently: true, + labels: ['Product', 'Update', 'New'], + newsfeed_assignments: [{ newsfeed_id: 103, published_at: 1664638214 }], + reactions: ['😆', '😅'], + state: 'live', + 'Intercom-Version': '2.11', + }); + }); + + test('retrieve', async () => { + const responsePromise = client.news.newsItems.retrieve(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.news.newsItems.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsItems.retrieve( + 123, + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update: only required params', async () => { + const responsePromise = client.news.newsItems.update(123, { + sender_id: 991268701, + title: 'Christmas is here!', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: required and optional params', async () => { + const response = await client.news.newsItems.update(123, { + sender_id: 991268701, + title: 'Christmas is here!', + body: '

New gifts in store for the jolly season

', + deliver_silently: true, + labels: ['Product', 'Update', 'New'], + newsfeed_assignments: [ + { newsfeed_id: 198313, published_at: 1674917488 }, + { newsfeed_id: 198313, published_at: 1674917488 }, + { newsfeed_id: 198313, published_at: 1674917488 }, + ], + reactions: ['😝', '😂'], + state: 'live', + 'Intercom-Version': '2.11', + }); + }); + + test('list', async () => { + const responsePromise = client.news.newsItems.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.news.newsItems.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsItems.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.news.newsItems.delete(123); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.news.newsItems.delete(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsItems.delete(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/news/newsfeeds/items.test.ts b/tests/api-resources/news/newsfeeds/items.test.ts new file mode 100644 index 00000000..91ec34c8 --- /dev/null +++ b/tests/api-resources/news/newsfeeds/items.test.ts @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource items', () => { + test('list', async () => { + const responsePromise = client.news.newsfeeds.items.list('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsfeeds.items.list('123', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsfeeds.items.list( + '123', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/news/newsfeeds/newsfeeds.test.ts b/tests/api-resources/news/newsfeeds/newsfeeds.test.ts new file mode 100644 index 00000000..b5d0c844 --- /dev/null +++ b/tests/api-resources/news/newsfeeds/newsfeeds.test.ts @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource newsfeeds', () => { + test('retrieve', async () => { + const responsePromise = client.news.newsfeeds.retrieve('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.news.newsfeeds.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsfeeds.retrieve( + '123', + { 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.news.newsfeeds.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.news.newsfeeds.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.news.newsfeeds.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/notes.test.ts b/tests/api-resources/notes.test.ts new file mode 100644 index 00000000..52250332 --- /dev/null +++ b/tests/api-resources/notes.test.ts @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource notes', () => { + test('retrieve', async () => { + const responsePromise = client.notes.retrieve(1); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.notes.retrieve(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.notes.retrieve(1, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/phone-call-redirects.test.ts b/tests/api-resources/phone-call-redirects.test.ts new file mode 100644 index 00000000..90fb9d6c --- /dev/null +++ b/tests/api-resources/phone-call-redirects.test.ts @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource phoneCallRedirects', () => { + test('create: only required params', async () => { + const responsePromise = client.phoneCallRedirects.create({ phone: '+353832345678' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.phoneCallRedirects.create({ + phone: '+353832345678', + custom_attributes: { issue_type: 'Billing', priority: 'High' }, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/segments.test.ts b/tests/api-resources/segments.test.ts new file mode 100644 index 00000000..510a4788 --- /dev/null +++ b/tests/api-resources/segments.test.ts @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource segments', () => { + test('retrieve', async () => { + const responsePromise = client.segments.retrieve('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.segments.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.segments.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.segments.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.segments.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.segments.list( + { include_count: true, 'Intercom-Version': '2.11' }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/subscription-types.test.ts b/tests/api-resources/subscription-types.test.ts new file mode 100644 index 00000000..8cf81d01 --- /dev/null +++ b/tests/api-resources/subscription-types.test.ts @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource subscriptionTypes', () => { + test('list', async () => { + const responsePromise = client.subscriptionTypes.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.subscriptionTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.subscriptionTypes.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/tags.test.ts b/tests/api-resources/tags.test.ts new file mode 100644 index 00000000..f057f08f --- /dev/null +++ b/tests/api-resources/tags.test.ts @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource tags', () => { + test('retrieve', async () => { + const responsePromise = client.tags.retrieve('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.tags.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.tags.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.tags.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.tags.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.tags.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('delete', async () => { + const responsePromise = client.tags.delete('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('delete: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.tags.delete('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('delete: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.tags.delete('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('createOrUpdate: only required params', async () => { + const responsePromise = client.tags.createOrUpdate({ name: 'Independent' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('createOrUpdate: required and optional params', async () => { + const response = await client.tags.createOrUpdate({ + name: 'Independent', + id: '656452352', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/teams.test.ts b/tests/api-resources/teams.test.ts new file mode 100644 index 00000000..93aef350 --- /dev/null +++ b/tests/api-resources/teams.test.ts @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource teams', () => { + test('retrieve', async () => { + const responsePromise = client.teams.retrieve('123'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.teams.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.teams.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.teams.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.teams.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.teams.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/ticket-types/attributes.test.ts b/tests/api-resources/ticket-types/attributes.test.ts new file mode 100644 index 00000000..3f4693db --- /dev/null +++ b/tests/api-resources/ticket-types/attributes.test.ts @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource attributes', () => { + test('create: only required params', async () => { + const responsePromise = client.ticketTypes.attributes.create('ticket_type_id', { + data_type: 'string', + description: 'Attribute Description', + name: 'Attribute Title', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.ticketTypes.attributes.create('ticket_type_id', { + data_type: 'string', + description: 'Attribute Description', + name: 'Attribute Title', + allow_multiple_values: false, + list_items: 'Low Priority,Medium Priority,High Priority', + multiline: false, + required_to_create: false, + required_to_create_for_contacts: false, + visible_on_create: true, + visible_to_contacts: true, + 'Intercom-Version': '2.11', + }); + }); + + test('update', async () => { + const responsePromise = client.ticketTypes.attributes.update('ticket_type_id', 'id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.ticketTypes.attributes.update('ticket_type_id', 'id', { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.ticketTypes.attributes.update( + 'ticket_type_id', + 'id', + { + allow_multiple_values: false, + archived: false, + description: 'New Attribute Description', + list_items: 'Low Priority,Medium Priority,High Priority', + multiline: false, + name: 'Bug Priority', + required_to_create: false, + required_to_create_for_contacts: false, + visible_on_create: true, + visible_to_contacts: true, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/ticket-types/ticket-types.test.ts b/tests/api-resources/ticket-types/ticket-types.test.ts new file mode 100644 index 00000000..b682a9c9 --- /dev/null +++ b/tests/api-resources/ticket-types/ticket-types.test.ts @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource ticketTypes', () => { + test('create: only required params', async () => { + const responsePromise = client.ticketTypes.create({ name: 'Customer Issue' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.ticketTypes.create({ + name: 'Customer Issue', + category: 'Customer', + description: 'Customer Report Template', + icon: '🎟️', + is_internal: false, + 'Intercom-Version': '2.11', + }); + }); + + test('retrieve', async () => { + const responsePromise = client.ticketTypes.retrieve('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.ticketTypes.retrieve('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieve: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.ticketTypes.retrieve('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('update', async () => { + const responsePromise = client.ticketTypes.update('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.ticketTypes.update('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('update: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.ticketTypes.update( + 'id', + { + archived: false, + category: 'Customer', + description: 'A bug has been occured', + icon: '🐞', + is_internal: false, + name: 'Bug Report 2', + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('list', async () => { + const responsePromise = client.ticketTypes.list(); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('list: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.ticketTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('list: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.ticketTypes.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/tickets/tags.test.ts b/tests/api-resources/tickets/tags.test.ts new file mode 100644 index 00000000..0cae5b55 --- /dev/null +++ b/tests/api-resources/tickets/tags.test.ts @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource tags', () => { + test('create: only required params', async () => { + const responsePromise = client.tickets.tags.create('64619700005694', { id: 'id', admin_id: 'admin_id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.tickets.tags.create('64619700005694', { + id: 'id', + admin_id: 'admin_id', + 'Intercom-Version': '2.11', + }); + }); + + test('remove: only required params', async () => { + const responsePromise = client.tickets.tags.remove('64619700005694', '7522907', { admin_id: 'admin_id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('remove: required and optional params', async () => { + const response = await client.tickets.tags.remove('64619700005694', '7522907', { + admin_id: 'admin_id', + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/api-resources/tickets/tickets.test.ts b/tests/api-resources/tickets/tickets.test.ts new file mode 100644 index 00000000..f71f5dd5 --- /dev/null +++ b/tests/api-resources/tickets/tickets.test.ts @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource tickets', () => { + test('create: only required params', async () => { + const responsePromise = client.tickets.create({ + contacts: [{ id: '6657af026abd0167d9419def' }], + ticket_type_id: 'ticket_type_id', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('create: required and optional params', async () => { + const response = await client.tickets.create({ + contacts: [{ id: '6657af026abd0167d9419def' }], + ticket_type_id: 'ticket_type_id', + company_id: '1234', + created_at: 1590000000, + ticket_attributes: { _default_title_: 'example', _default_description_: 'there is a problem' }, + 'Intercom-Version': '2.11', + }); + }); + + test('reply: only required params', async () => { + const responsePromise = client.tickets.reply('123', { + body: 'body', + message_type: 'comment', + type: 'user', + }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('reply: required and optional params', async () => { + const response = await client.tickets.reply('123', { + body: 'body', + message_type: 'comment', + type: 'user', + attachment_urls: ['https://example.com', 'https://example.com', 'https://example.com'], + created_at: 1590000000, + 'Intercom-Version': '2.11', + }); + }); + + test('retrieveById', async () => { + const responsePromise = client.tickets.retrieveById('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieveById: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.tickets.retrieveById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('retrieveById: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.tickets.retrieveById('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + ).rejects.toThrow(Intercom.NotFoundError); + }); + + test('search: only required params', async () => { + const responsePromise = client.tickets.search({ query: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('search: required and optional params', async () => { + const response = await client.tickets.search({ + query: { field: 'created_at', operator: '=', value: 'value' }, + pagination: { per_page: 5, starting_after: 'your-cursor-from-response' }, + 'Intercom-Version': '2.11', + }); + }); + + test('updateById', async () => { + const responsePromise = client.tickets.updateById('id'); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('updateById: request options instead of params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect(client.tickets.updateById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + Intercom.NotFoundError, + ); + }); + + test('updateById: request options and params are passed correctly', async () => { + // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error + await expect( + client.tickets.updateById( + 'id', + { + assignment: { admin_id: '991268839', assignee_id: '991268841' }, + is_shared: true, + open: true, + snoozed_until: 1673609604, + state: 'in_progress', + ticket_attributes: { _default_title_: 'example', _default_description_: 'there is a problem' }, + 'Intercom-Version': '2.11', + }, + { path: '/_stainless_unknown_path' }, + ), + ).rejects.toThrow(Intercom.NotFoundError); + }); +}); diff --git a/tests/api-resources/visitors.test.ts b/tests/api-resources/visitors.test.ts new file mode 100644 index 00000000..b3f217b3 --- /dev/null +++ b/tests/api-resources/visitors.test.ts @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { Response } from 'node-fetch'; + +const client = new Intercom({ + accessToken: 'My Access Token', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource visitors', () => { + test('retrieve: only required params', async () => { + const responsePromise = client.visitors.retrieve({ user_id: 'user_id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('retrieve: required and optional params', async () => { + const response = await client.visitors.retrieve({ user_id: 'user_id', 'Intercom-Version': '2.11' }); + }); + + test('update: only required params', async () => { + const responsePromise = client.visitors.update({ body: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('update: required and optional params', async () => { + const response = await client.visitors.update({ body: {}, 'Intercom-Version': '2.11' }); + }); + + test('convert: only required params', async () => { + const responsePromise = client.visitors.convert({ type: 'user', user: {}, visitor: {} }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + test('convert: required and optional params', async () => { + const response = await client.visitors.convert({ + type: 'user', + user: { + id: '8a88a590-e1c3-41e2-a502-e0649dbf721c', + user_id: '8a88a590-e1c3-41e2-a502-e0649dbf721c', + email: 'foo@bar.com', + }, + visitor: { + id: '8a88a590-e1c3-41e2-a502-e0649dbf721c', + user_id: '3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3', + email: 'winstonsmith@truth.org', + }, + 'Intercom-Version': '2.11', + }); + }); +}); diff --git a/tests/custom.test.ts b/tests/custom.test.ts deleted file mode 100644 index 7f5e031c..00000000 --- a/tests/custom.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This is a custom test file, if you wish to add more tests - * to your SDK. - * Be sure to mark this file in `.fernignore`. - * - * If you include example requests/responses in your fern definition, - * you will have tests automatically generated for you. - */ -describe("test", () => { - it("default", () => { - expect(true).toBe(true); - }); -}); diff --git a/tests/form.test.ts b/tests/form.test.ts new file mode 100644 index 00000000..f93402ef --- /dev/null +++ b/tests/form.test.ts @@ -0,0 +1,65 @@ +import { multipartFormRequestOptions, createForm } from 'intercom-client/core'; +import { Blob } from 'intercom-client/_shims/index'; +import { toFile } from 'intercom-client'; + +describe('form data validation', () => { + test('valid values do not error', async () => { + await multipartFormRequestOptions({ + body: { + foo: 'foo', + string: 1, + bool: true, + file: await toFile(Buffer.from('some-content')), + blob: new Blob(['Some content'], { type: 'text/plain' }), + }, + }); + }); + + test('null', async () => { + await expect(() => + multipartFormRequestOptions({ + body: { + null: null, + }, + }), + ).rejects.toThrow(TypeError); + }); + + test('undefined is stripped', async () => { + const form = await createForm({ + foo: undefined, + bar: 'baz', + }); + expect(form.has('foo')).toBe(false); + expect(form.get('bar')).toBe('baz'); + }); + + test('nested undefined property is stripped', async () => { + const form = await createForm({ + bar: { + baz: undefined, + }, + }); + expect(Array.from(form.entries())).toEqual([]); + + const form2 = await createForm({ + bar: { + foo: 'string', + baz: undefined, + }, + }); + expect(Array.from(form2.entries())).toEqual([['bar[foo]', 'string']]); + }); + + test('nested undefined array item is stripped', async () => { + const form = await createForm({ + bar: [undefined, undefined], + }); + expect(Array.from(form.entries())).toEqual([]); + + const form2 = await createForm({ + bar: [undefined, 'foo'], + }); + expect(Array.from(form2.entries())).toEqual([['bar[]', 'foo']]); + }); +}); diff --git a/tests/index.test.ts b/tests/index.test.ts new file mode 100644 index 00000000..56912c99 --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Intercom from 'intercom-client'; +import { APIUserAbortError } from 'intercom-client'; +import { Headers } from 'intercom-client/core'; +import defaultFetch, { Response, type RequestInit, type RequestInfo } from 'node-fetch'; + +describe('instantiate client', () => { + const env = process.env; + + beforeEach(() => { + jest.resetModules(); + process.env = { ...env }; + + console.warn = jest.fn(); + }); + + afterEach(() => { + process.env = env; + }); + + describe('defaultHeaders', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-My-Default-Header': '2' }, + accessToken: 'My Access Token', + }); + + test('they are used in the request', () => { + const { req } = client.buildRequest({ path: '/foo', method: 'post' }); + expect((req.headers as Headers)['x-my-default-header']).toEqual('2'); + }); + + test('can ignore `undefined` and leave the default', () => { + const { req } = client.buildRequest({ + path: '/foo', + method: 'post', + headers: { 'X-My-Default-Header': undefined }, + }); + expect((req.headers as Headers)['x-my-default-header']).toEqual('2'); + }); + + test('can be removed with `null`', () => { + const { req } = client.buildRequest({ + path: '/foo', + method: 'post', + headers: { 'X-My-Default-Header': null }, + }); + expect(req.headers as Headers).not.toHaveProperty('x-my-default-header'); + }); + }); + + describe('defaultQuery', () => { + test('with null query params given', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo' }, + accessToken: 'My Access Token', + }); + expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo'); + }); + + test('multiple default query params', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo', hello: 'world' }, + accessToken: 'My Access Token', + }); + expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo&hello=world'); + }); + + test('overriding with `undefined`', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/', + defaultQuery: { hello: 'world' }, + accessToken: 'My Access Token', + }); + expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo'); + }); + }); + + test('custom fetch', async () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/', + accessToken: 'My Access Token', + fetch: (url) => { + return Promise.resolve( + new Response(JSON.stringify({ url, custom: true }), { + headers: { 'Content-Type': 'application/json' }, + }), + ); + }, + }); + + const response = await client.get('/foo'); + expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true }); + }); + + test('custom signal', async () => { + const client = new Intercom({ + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', + accessToken: 'My Access Token', + fetch: (...args) => { + return new Promise((resolve, reject) => + setTimeout( + () => + defaultFetch(...args) + .then(resolve) + .catch(reject), + 300, + ), + ); + }, + }); + + const controller = new AbortController(); + setTimeout(() => controller.abort(), 200); + + const spy = jest.spyOn(client, 'request'); + + await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError(APIUserAbortError); + expect(spy).toHaveBeenCalledTimes(1); + }); + + describe('baseUrl', () => { + test('trailing slash', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/custom/path/', + accessToken: 'My Access Token', + }); + expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); + }); + + test('no trailing slash', () => { + const client = new Intercom({ + baseURL: 'http://localhost:5000/custom/path', + accessToken: 'My Access Token', + }); + expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/custom/path/foo'); + }); + + afterEach(() => { + process.env['INTERCOM_BASE_URL'] = undefined; + }); + + test('explicit option', () => { + const client = new Intercom({ baseURL: 'https://example.com', accessToken: 'My Access Token' }); + expect(client.baseURL).toEqual('https://example.com'); + }); + + test('env variable', () => { + process.env['INTERCOM_BASE_URL'] = 'https://example.com/from_env'; + const client = new Intercom({ accessToken: 'My Access Token' }); + expect(client.baseURL).toEqual('https://example.com/from_env'); + }); + + test('empty env variable', () => { + process.env['INTERCOM_BASE_URL'] = ''; // empty + const client = new Intercom({ accessToken: 'My Access Token' }); + expect(client.baseURL).toEqual('https://api.intercom.io'); + }); + + test('blank env variable', () => { + process.env['INTERCOM_BASE_URL'] = ' '; // blank + const client = new Intercom({ accessToken: 'My Access Token' }); + expect(client.baseURL).toEqual('https://api.intercom.io'); + }); + + test('env variable with environment', () => { + process.env['INTERCOM_BASE_URL'] = 'https://example.com/from_env'; + + expect( + () => new Intercom({ accessToken: 'My Access Token', environment: 'us' }), + ).toThrowErrorMatchingInlineSnapshot( + `"Ambiguous URL; The \`baseURL\` option (or INTERCOM_BASE_URL env var) and the \`environment\` option are given. If you want to use the environment you must pass baseURL: null"`, + ); + + const client = new Intercom({ accessToken: 'My Access Token', baseURL: null, environment: 'us' }); + expect(client.baseURL).toEqual('https://api.intercom.io'); + }); + }); + + test('maxRetries option is correctly set', () => { + const client = new Intercom({ maxRetries: 4, accessToken: 'My Access Token' }); + expect(client.maxRetries).toEqual(4); + + // default + const client2 = new Intercom({ accessToken: 'My Access Token' }); + expect(client2.maxRetries).toEqual(2); + }); + + test('with environment variable arguments', () => { + // set options via env var + process.env['INTERCOM_ACCESS_TOKEN'] = 'My Access Token'; + const client = new Intercom(); + expect(client.accessToken).toBe('My Access Token'); + }); + + test('with overriden environment variable arguments', () => { + // set options via env var + process.env['INTERCOM_ACCESS_TOKEN'] = 'another My Access Token'; + const client = new Intercom({ accessToken: 'My Access Token' }); + expect(client.accessToken).toBe('My Access Token'); + }); +}); + +describe('request building', () => { + const client = new Intercom({ accessToken: 'My Access Token' }); + + describe('Content-Length', () => { + test('handles multi-byte characters', () => { + const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: '—' } }); + expect((req.headers as Record)['content-length']).toEqual('20'); + }); + + test('handles standard characters', () => { + const { req } = client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' } }); + expect((req.headers as Record)['content-length']).toEqual('22'); + }); + }); + + describe('custom headers', () => { + test('handles undefined', () => { + const { req } = client.buildRequest({ + path: '/foo', + method: 'post', + body: { value: 'hello' }, + headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null }, + }); + expect((req.headers as Record)['x-foo']).toEqual('bar'); + expect((req.headers as Record)['x-Foo']).toEqual(undefined); + expect((req.headers as Record)['X-Foo']).toEqual(undefined); + expect((req.headers as Record)['x-baz']).toEqual(undefined); + }); + }); +}); + +describe('retries', () => { + test('retry on timeout', async () => { + let count = 0; + const testFetch = async (url: RequestInfo, { signal }: RequestInit = {}): Promise => { + if (count++ === 0) { + return new Promise( + (resolve, reject) => signal?.addEventListener('abort', () => reject(new Error('timed out'))), + ); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; + + const client = new Intercom({ accessToken: 'My Access Token', timeout: 10, fetch: testFetch }); + + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); + + test('retry on 429 with retry-after', async () => { + let count = 0; + const testFetch = async (url: RequestInfo, { signal }: RequestInit = {}): Promise => { + if (count++ === 0) { + return new Response(undefined, { + status: 429, + headers: { + 'Retry-After': '0.1', + }, + }); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; + + const client = new Intercom({ accessToken: 'My Access Token', fetch: testFetch }); + + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); + + test('retry on 429 with retry-after-ms', async () => { + let count = 0; + const testFetch = async (url: RequestInfo, { signal }: RequestInit = {}): Promise => { + if (count++ === 0) { + return new Response(undefined, { + status: 429, + headers: { + 'Retry-After-Ms': '10', + }, + }); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; + + const client = new Intercom({ accessToken: 'My Access Token', fetch: testFetch }); + + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); +}); diff --git a/tests/integration/admins.test.ts b/tests/integration/admins.test.ts deleted file mode 100644 index 8302bf1b..00000000 --- a/tests/integration/admins.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { createClient } from "./utils/createClient"; - -describe("Admins", () => { - let adminId: string; - const client = createClient(); - - beforeAll(async () => { - // arrange - const adminList = await client.admins.list(); - adminId = adminList.admins[0].id; - }); - - it("list", async () => { - // act - const response = await client.admins.list(); - - // assert - expect(response).toBeDefined(); - }); - it("find", async () => { - // act - const response = await client.admins.find({ admin_id: adminId }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAllActivityLogs", async () => { - // act - const response = await client.admins.listAllActivityLogs({ - created_at_after: new Date("2021-12-12").toISOString(), - created_at_before: new Date("2022-01-01").toISOString(), - }); - - // assert - expect(response).toBeDefined(); - }); - - it("away - ON", async () => { - // act - const response = await client.admins.away({ - admin_id: adminId, - away_mode_enabled: true, - away_mode_reassign: true, - }); - - // assert - expect(response).toBeDefined(); - }); - it("away - OFF", async () => { - // act - const response = await client.admins.away({ - admin_id: adminId, - away_mode_enabled: false, - away_mode_reassign: false, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/articles.test.ts b/tests/integration/articles.test.ts deleted file mode 100644 index d7e0dc2d..00000000 --- a/tests/integration/articles.test.ts +++ /dev/null @@ -1,114 +0,0 @@ -import { IntercomClient as Client } from "../../src"; -import { randomString } from "./utils/random"; -import { createClient } from "./utils/createClient"; - -async function createArticle(client: Client, parentId: number, adminId: number) { - return await client.articles.create({ - title: randomString(), - description: randomString(), - body: "Eins Zwei", - author_id: adminId, - state: "draft", - parent_id: parentId, - parent_type: "collection", - translated_content: { - fr: { - type: "article_content", - title: "Allez les verts", - description: "French description", - body: "

French body in html

", - author_id: adminId, - state: "draft", - }, - }, - }); -} - -async function tryDeleteArticle(client: Client, articleId: string) { - try { - await client.articles.delete({ article_id: articleId }); - } catch (error) { - console.error("Failed to delete article:", error); - } -} - -describe("Articles", () => { - let articleId: string; - let parentId: number; - let adminId: number; - const client = createClient(); - - beforeAll(async () => { - // arrange - const randomCollections = await client.helpCenters.collections.list({ - per_page: 1, - }); - const randomAdmins = await client.admins.list(); - - parentId = parseInt(randomCollections.data[0].id, 10); - adminId = parseInt(randomAdmins.admins[0].id, 10); - - const article = await createArticle(client, parentId, adminId); - articleId = article.id; - }); - - afterAll(async () => { - // cleanup - await tryDeleteArticle(client, articleId); - }); - - it("create", async () => { - // act - const article = await createArticle(client, parentId, adminId); - - // assert - expect(article).toBeDefined(); - - // cleanup - await tryDeleteArticle(client, article.id); - }); - - it("find", async () => { - // act - const response = await client.articles.find({ article_id: articleId }); - - // assert - expect(response).toBeDefined(); - }); - - it("update", async () => { - // arrange - const article = await createArticle(client, parentId, adminId); - - // act - const response = await client.articles.update({ - article_id: article.id, - title: "Biba & Boba", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteArticle(client, article.id); - }); - - it("list", async () => { - // act - const response = await client.articles.list({ page: 1, per_page: 12 }); - - // assert - expect(response).toBeDefined(); - }); - - it("delete", async () => { - // arrange - const article = await createArticle(client, parentId, adminId); - - // act - const response = await client.articles.delete({ article_id: article.id }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/companies.test.ts b/tests/integration/companies.test.ts deleted file mode 100644 index 078d81ee..00000000 --- a/tests/integration/companies.test.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { Intercom } from "../../src"; -import { dateToUnixTimestamp } from "./utils/date"; -import { createCompany, tryDeleteCompany } from "./helpers"; -import { createClient } from "./utils/createClient"; - -describe("Companies", () => { - let contactId: string; - let company: Intercom.Company; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const randomContacts = await client.contacts.list({ - per_page: 1, - }); - - contactId = randomContacts.data[0].id; - company = await createCompany(client); - }); - - afterAll(async () => { - // cleanup - await tryDeleteCompany(client, company.id); - }); - - it("create", async () => { - // act - const company = await createCompany(client); - - // assert - expect(company).toBeDefined(); - - // cleanup - await tryDeleteCompany(client, company.id); - }); - - it("update", async () => { - // arrange - const company = await createCompany(client); - - // act - const response = await client.companies.createOrUpdate({ - company_id: company.company_id, - remote_created_at: dateToUnixTimestamp(new Date()), - name: "BestCompanyInc", - monthly_spend: 9001, - plan: "1. Get pizzaid", - size: 62049, - website: "http://the-best.one", - industry: "The Best One", - custom_attributes: {}, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteCompany(client, company.id); - }); - - it("find - by id", async () => { - // act - const response = await client.companies.find({ - company_id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("list", async () => { - // act - const response = await client.companies.list({ - page: 1, - per_page: 35, - order: "desc", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("delete", async () => { - // arrange - const company = await createCompany(client); - - // act - const response = await client.companies.delete({ - company_id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it.skip("scroll - infinite one", async () => { - // act - const response = await client.companies.scroll(); - - // assert - expect(response.data).toBeDefined(); - }); - - it("attachContact", async () => { - // act - const response = await client.companies.attachContact({ - contact_id: contactId, - id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("detachContact", async () => { - // act - const response = await client.companies.detachContact({ - contact_id: contactId, - company_id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAttachedContacts", async () => { - // act - const response = await client.companies.listAttachedContacts({ - company_id: company.id, - page: 1, - per_page: 25, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAttachedSegments", async () => { - // act - const response = await client.companies.listAttachedSegments({ - company_id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/contacts.test.ts b/tests/integration/contacts.test.ts deleted file mode 100644 index 633714dc..00000000 --- a/tests/integration/contacts.test.ts +++ /dev/null @@ -1,243 +0,0 @@ -import { Intercom } from "../../src"; -import { dateToUnixTimestamp } from "./utils/date"; -import { randomString } from "./utils/random"; -import { createContact, tryDeleteCompany, tryDeleteContact, tryUntagContact } from "./helpers"; -import { createClient } from "./utils/createClient"; - -describe("Contacts", () => { - let subscriptionId: string; - let tag: Intercom.Tag; - let contact: Intercom.Contact; - let company: Intercom.Company; - - const client = createClient(); - - beforeAll(async () => { - // arrange - contact = await createContact(client); - - company = await client.companies.createOrUpdate({ - remote_created_at: dateToUnixTimestamp(new Date()), - company_id: randomString(), - name: randomString(), - monthly_spend: 9001, - plan: "1. Get pizzaid", - size: 62049, - website: "http://the-best.one", - industry: "The Best One", - custom_attributes: {}, - }); - - await client.companies.attachContact({ - id: company.id, - contact_id: contact.id, - }); - - const subscriptionTypes = await client.subscriptionTypes.list(); - subscriptionId = subscriptionTypes.data[0].id; - await client.contacts.attachSubscription({ - contact_id: contact.id, - id: subscriptionId, - consent_type: "opt_in", - }); - - tag = await client.tags.create({ - name: randomString(), - }); - await client.tags.tagContact({ - contact_id: contact.id, - id: tag.id, - }); - }); - - afterAll(async () => { - // cleanup - try { - await client.contacts.detachSubscription({ - contact_id: contact.id, - subscription_id: subscriptionId, - }); - } catch (error) { - console.error("Failed to detach subscription:", error); - } - await tryUntagContact(client, contact.id, tag.id); - await tryDeleteCompany(client, company.id); - await tryDeleteContact(client, contact.id); - }); - - it("list", async () => { - // act - const response = await client.contacts.list({ - per_page: 5, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("createUser", async () => { - // act - const response = await client.contacts.create({ - external_id: randomString(), - phone: "+353871234567", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, response.id); - }); - - it("createLead", async () => { - // act - const response = await client.contacts.create({ - name: "Roman Bowling", - role: "lead", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, response.id); - }); - - it("find - by id", async () => { - // act - const response = await client.contacts.find({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("update", async () => { - // arrange - const contact = await createContact(client); - - // act - const response = await client.contacts.update({ - contact_id: contact.id, - name: "Nico Bellic", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, contact.id); - }); - - it("archive", async () => { - // arrange - const contact = await createContact(client); - - // act - const response = await client.contacts.archive({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, contact.id); - }); - - it("unarchive", async () => { - // arrange - const contact = await createContact(client); - - // act - const response = await client.contacts.unarchive({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, contact.id); - }); - - it("delete", async () => { - // arrange - const contact = await client.contacts.create({ - external_id: randomString(), - phone: "+353871234567", - }); - - // act - const response = await client.contacts.delete({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("mergeLeadInUser", async () => { - // arrange - const createdUser = await client.contacts.create({ - external_id: randomString(), - phone: "+353871234567", - }); - const createdLead = await client.contacts.create({ - name: "Roman Bowling", - role: "lead", - }); - const response = await client.contacts.mergeLeadInUser({ - from: createdLead.id, - into: createdUser.id, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, createdUser.id); - await tryDeleteContact(client, createdLead.id); - }); - - it("listAttachedCompanies", async () => { - // act - const response = await client.contacts.listAttachedCompanies({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAttachedEmailSubscriptions", async () => { - // act - const response = await client.contacts.listAttachedSubscriptions({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAttachedSegments", async () => { - // act - const response = await client.contacts.listAttachedSegments({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("listAttachedTags", async () => { - // act - const response = await client.contacts.listAttachedTags({ - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/conversations.test.ts b/tests/integration/conversations.test.ts deleted file mode 100644 index fed0a9b9..00000000 --- a/tests/integration/conversations.test.ts +++ /dev/null @@ -1,288 +0,0 @@ -import { Intercom } from "../../src"; -import { createConversation, tryDeleteContact } from "./helpers"; -import { createClient } from "./utils/createClient"; -import { randomString } from "./utils/random"; -import { wait } from "./utils/wait"; - -describe("Conversations", () => { - let user: Intercom.Contact; - let secondUser: Intercom.Contact; - let lead: Intercom.Contact; - - let adminId: string; - let secondAdminId: string; - let conversationId: string; - let conversation: Intercom.Conversation; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const admins = await client.admins.list(); - - const adminList = admins.admins.filter((admin) => admin.has_inbox_seat); - // Only admins with inbox seat can interact with conversations. - adminId = adminList[0].id; - secondAdminId = adminList[1].id; - user = await client.contacts.create({ - external_id: randomString(), - name: "Baba Booey", - }); - secondUser = await client.contacts.create({ - external_id: randomString(), - name: "Babushka Boy", - email: `${randomString()}@bababooey.com`, - }); - lead = await client.contacts.create({ - external_id: randomString(), - name: "Babushka Lead", - email: `${randomString()}@bababooey.com`, - role: "lead", - }); - - const conversationMessage = await client.conversations.create({ - from: { id: user.id, type: "user" }, - body: "Raz-dwa-try kalyna, czorniawaja diwczyna", - }); - conversationId = conversationMessage.conversation_id; - - // Give Intercom a few seconds to index conversation - await wait(5000); - - conversation = await client.conversations.find({ - conversation_id: conversationId, - }); - }, 20_000); - - afterAll(async () => { - // cleanup - await tryDeleteContact(client, user.id); - await tryDeleteContact(client, secondUser.id); - await tryDeleteContact(client, lead.id); - }); - - it("create conversation with user as default", async () => { - // act - const response = await client.conversations.create({ - from: { id: user.id, type: "user" }, - body: "Raz-dwa-try kalyna, czorniawaja diwczyna", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("create conversation with user", async () => { - // act - const response = await client.conversations.create({ - from: { id: user.id, type: "user" }, - body: "Raz-dwa-try kalyna, czorniawaja diwczyna", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("create conversation with lead", async () => { - // act - const response = await client.conversations.create({ - from: { id: lead.id, type: "lead" }, - body: "Raz-dwa-try kalyna, czorniawaja diwczyna", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("find - by id", async () => { - // act - const response = await client.conversations.find({ - conversation_id: conversationId, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("update", async () => { - // act - const response = await client.conversations.update({ - conversation_id: conversationId, - read: false, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("replyByIdAsAdmin", async () => { - // act - const response = await client.conversations.reply({ - conversation_id: conversationId, - body: { - message_type: "comment", - type: "admin", - body: "test", - admin_id: adminId, - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("replyByIdAsUser", async () => { - // act - const response = await client.conversations.reply({ - conversation_id: conversationId, - body: { - message_type: "comment", - type: "user", - body: "*click* Nice!", - intercom_user_id: user.id, - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("assign", async () => { - // arrange - const message = await createConversation(client, user.id); - - // act - const response = await client.conversations.manage({ - conversation_id: message.conversation_id, - body: { - message_type: "assignment", - type: "admin", - admin_id: adminId, - assignee_id: secondAdminId, - body: "Goodbye :)", - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("run assignment rules", async () => { - const legacyClient = createClient({ version: "2.11" }); - // arrange - const message = await createConversation(legacyClient, user.id); - - // act - const response = await legacyClient.conversations.runAssignmentRules({ - conversation_id: message.conversation_id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("snooze", async () => { - // act - const response = await client.conversations.manage({ - conversation_id: conversationId, - body: { - message_type: "snoozed", - admin_id: adminId, - snoozed_until: new Date("2040.06.19").getTime() / 1000, - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("open", async () => { - // act - const response = await client.conversations.manage({ - conversation_id: conversationId, - body: { - message_type: "open", - admin_id: adminId, - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("attachContactAsAdmin", async () => { - // act - const response = await client.conversations.attachContactAsAdmin({ - conversation_id: conversationId, - customer: { intercom_user_id: secondUser.id }, - admin_id: adminId, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("detachContactAsAdmin", async () => { - // act - const response = await client.conversations.detachContactAsAdmin({ - admin_id: adminId, - contact_id: secondUser.id, - conversation_id: conversationId, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("redactConversationPart", async () => { - // arrange - const conversation = await client.conversations.find({ - conversation_id: conversationId, - }); - - // act - const response = await client.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: conversationId, - conversation_part_id: conversation.conversation_parts?.conversation_parts[2].id ?? "", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("close", async () => { - // act - const response = await client.conversations.manage({ - conversation_id: conversationId, - body: { - type: "admin", - message_type: "close", - admin_id: adminId, - body: "Hasta la vista, baby", - } - }); - - // assert - expect(response).toBeDefined(); - }); - - it("search", async () => { - // act - const response = await client.conversations.search({ - query: { - operator: "AND", - value: [ - { - field: "id", - operator: "!=", - value: "123", - }, - ], - }, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/dataAttributes.test.ts b/tests/integration/dataAttributes.test.ts deleted file mode 100644 index f5889fa2..00000000 --- a/tests/integration/dataAttributes.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Intercom } from "../../src"; -import { randomString } from "./utils/random"; -import { createClient } from "./utils/createClient"; - -describe("Data Attributes", () => { - let randomDataAttribute: Intercom.DataAttribute | undefined; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const attributes = await client.dataAttributes.list(); - randomDataAttribute = attributes.data.find((attribute) => attribute.id !== undefined); - }); - - it.skip("create", async () => { - //act - - // The workspace we test on has hit the CDA limit, so we can't create any more - // for now. We should reenable this test once we have a new workspace. - const response = await client.dataAttributes.create({ - name: `Bebech${randomString()}`, - model: "contact", - data_type: "string", - description: "Dummy description", - options: ["yey", "yoy"], - }); - - // assert - expect(response).toBeDefined(); - }); - it("update", async () => { - // arrange - if (!randomDataAttribute?.id) { - console.log("randomDataAttribute", randomDataAttribute); - throw new Error("random_data_attribute.id is required to update"); - } - - // act - const response = await client.dataAttributes.update({ - data_attribute_id: randomDataAttribute.id.toString(), - archived: false, - description: "Woo-aaa", - options: [ - { - value: "1-10", - }, - { - value: "11-20", - }, - ], - }); - - // assert - expect(response).toBeDefined(); - }); - it("list", async () => { - // act - const response = await client.dataAttributes.list({ - include_archived: true, - model: "conversation", - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/dataExport.test.ts b/tests/integration/dataExport.test.ts deleted file mode 100644 index a26d014a..00000000 --- a/tests/integration/dataExport.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Intercom, IntercomClient } from "../../src"; -import { createClient } from "./utils/createClient"; - -async function createDataExport(client: IntercomClient): Promise { - const dataExport = await client.dataExport.create({ - created_at_after: 1670000000, - created_at_before: 1670940528, - }); - return dataExport; -} - -async function tryCancelDataExport(client: IntercomClient, jobIdentifier: string): Promise { - try { - await client.dataExport.cancel({ job_identifier: jobIdentifier }); - } catch (error: unknown) { - console.log(error); - } -} - -describe("dataExport", () => { - const client = createClient(); - it("create", async () => { - // act - const response = await createDataExport(client); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryCancelDataExport(client, response.job_identifier); - }); - - it("find", async () => { - // arrange - const dataExport = await createDataExport(client); - - // act - const response = await client.dataExport.find({ job_identifier: dataExport.job_identifier }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryCancelDataExport(client, dataExport.job_identifier); - }); - - it("cancel", async () => { - // arrange - const dataExport = await createDataExport(client); - - // act - const response = await client.dataExport.cancel({ job_identifier: dataExport.job_identifier }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/events.test.ts b/tests/integration/events.test.ts deleted file mode 100644 index d86c25c9..00000000 --- a/tests/integration/events.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { IntercomClient as Client } from "../../src"; -import { dateToUnixTimestamp } from "./utils/date"; -import { randomString } from "./utils/random"; -import { createClient } from "./utils/createClient"; - -describe("Events", () => { - let userId: string; - let eventId = randomString(); - - const client = createClient(); - - beforeAll(async () => { - // arrange - const randomUsers = await client.contacts.search({ - query: { - operator: "AND", - value: [ - { - field: "role", - operator: "=", - value: "user", - }, - { - field: "external_id", - operator: "!=", - value: undefined, - }, - ], - }, - pagination: { - per_page: 1, - }, - }); - userId = randomUsers.data[0].external_id || ""; - if (!userId) { - console.warn("user_id is required to run tests"); - } - }); - - it("create", async () => { - // act - expect( - async () => - await client.events.create({ - id: eventId, - user_id: userId, - event_name: "opinion-rejected", - created_at: dateToUnixTimestamp(new Date()), - metadata: { - guidance: "provided", - wereall: "gonna make it", - price: "9001", - }, - }) - ).not.toThrowError(); - }); - - // expected to fail for now - it("listBy", async () => { - const response = await client.events.list({ - type: "user", - user_id: userId, - per_page: 2, - summary: true, - }); - - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/helpCenter/collections.test.ts b/tests/integration/helpCenter/collections.test.ts deleted file mode 100644 index 6dcfd781..00000000 --- a/tests/integration/helpCenter/collections.test.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { IntercomClient as Client } from "../../../src"; -import { Collection } from "../../../src/api/resources/helpCenter/types"; -import { createClient } from "../utils/createClient"; - -async function createCollection(client: Client): Promise { - return await client.helpCenters.collections.create({ - name: "The Bruh Moment", - description: "Bruuuuuh", - translated_content: { - type: "group_translated_content", - fr: { - type: "group_content", - name: "Le Moment Frère", - description: "Frèèèèère", - }, - }, - }); -} - -async function tryDeleteCollection(client: Client, collectionId: string) { - try { - await client.helpCenters.collections.delete({ collection_id: collectionId }); - } catch (error) { - console.log(error); - } -} - -describe("Collections", () => { - let collectionId: string; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const collection = await createCollection(client); - collectionId = collection.id; - }); - - afterAll(async () => { - // cleanup - await tryDeleteCollection(client, collectionId); - }); - - it("create", async () => { - // act - const collection = await createCollection(client); - - // assert - expect(collection).toBeDefined(); - - // cleanup - await tryDeleteCollection(client, collection.id); - }); - - it("find", async () => { - // act - const response = await client.helpCenters.collections.find({ - collection_id: collectionId, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("update", async () => { - // arrange - const collection = await createCollection(client); - - // act - const response = await client.helpCenters.collections.update({ - collection_id: collection.id, - name: "People of future, tell us if NFTs make sense in 2026", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteCollection(client, collection.id); - }); - - it("list", async () => { - // act - const response = await client.helpCenters.collections.list({ - per_page: 25, - page: 1, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("delete", async () => { - // arrange - const collection = await createCollection(client); - - // act - const response = await client.helpCenters.collections.delete({ - collection_id: collection.id, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/helpers.ts b/tests/integration/helpers.ts deleted file mode 100644 index 0d358442..00000000 --- a/tests/integration/helpers.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { Intercom, IntercomClient } from "../../src"; -import { dateToUnixTimestamp } from "./utils/date"; -import { randomString } from "./utils/random"; - -export async function createCompany(client: IntercomClient) { - return await client.companies.createOrUpdate({ - remote_created_at: dateToUnixTimestamp(new Date()), - company_id: randomString(), - name: randomString(), - monthly_spend: 9001, - plan: "1. Get pizzaid", - size: 62049, - website: "http://the-best.one", - industry: "The Best One", - custom_attributes: {}, - }); -} - -export async function tryDeleteCompany(client: IntercomClient, companyId: string) { - try { - await client.companies.delete({ company_id: companyId }); - } catch (error) { - console.error("Failed to delete company:", error); - } -} - -export async function createContact(client: IntercomClient) { - return await client.contacts.create({ - external_id: randomString(), - phone: "+353871234567", - }); -} - -export async function tryDeleteContact(client: IntercomClient, contactId: string) { - try { - await client.contacts.delete({ contact_id: contactId }); - } catch (error) { - console.error("Failed to delete contact:", error); - } -} - -export async function tryDeleteTag(client: IntercomClient, tagId: string) { - try { - await client.tags.delete({ tag_id: tagId }); - } catch (error) { - console.error(error); - } -} - -export async function createConversation(client: IntercomClient, contactId: string) { - return await client.conversations.create({ - from: { id: contactId, type: "user" }, - body: randomString(), - }); -} - -export async function tryUntagContact(client: IntercomClient, contactId: string, tagId: string) { - try { - await client.tags.untagContact({ contact_id: contactId, tag_id: tagId }); - } catch (error) { - console.error(error); - } -} - -export async function tryUntagConversation( - client: IntercomClient, - conversationId: string, - tagId: string, - adminId: string -) { - try { - await client.tags.untagConversation({ conversation_id: conversationId, tag_id: tagId, admin_id: adminId }); - } catch (error) { - console.error(error); - } -} - -export async function tryUntagCompany(client: IntercomClient, tagName: string, company: Intercom.Company) { - try { - await client.tags.create({ - name: tagName, - companies: [{ id: company.id, company_id: company.company_id, untag: true }], - }); - } catch (error) { - console.error(error); - } -} diff --git a/tests/integration/integration.test.ts b/tests/integration/integration.test.ts deleted file mode 100644 index 321552f6..00000000 --- a/tests/integration/integration.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { Intercom } from "../../src"; -import { randomString } from "./utils/random"; -import { createCompany, tryDeleteCompany, tryDeleteContact, tryDeleteTag } from "./helpers"; -import { createClient } from "./utils/createClient"; - -describe("Integration between Contact, Conversation, Company and Tag APIs", () => { - let adminId: string; - let company: Intercom.Company; - let user: Intercom.Contact; - let lead: Intercom.Contact; - let tag: Intercom.Tag; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const admins = await client.admins.list(); - adminId = admins.admins[0].id; - - company = await createCompany(client); - user = await client.contacts.create({ - external_id: randomString(), - }); - lead = await client.contacts.create({ - name: "Marek Barek", - role: "lead", - }); - tag = await client.tags.create({ - name: randomString(), - }); - }); - - afterAll(async () => { - // cleanup - await tryDeleteContact(client, lead.id); - await tryDeleteContact(client, user.id); - await tryDeleteCompany(client, company.id); - await tryDeleteTag(client, tag.id); - }); - - it("Add Contact to Company", async () => { - // act - const response = await client.companies.attachContact({ - contact_id: user.id, - id: company.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("Create Conversation with Contact", async () => { - // act - const response = await client.conversations.create({ - from: { - type: "user", - id: user.id, - }, - body: "Welcome to the club, buddy!", - }); - - // assert - expect(response).toBeDefined(); - }); - - it("Tag the Conversation", async () => { - // arrange - const conversation = await client.conversations.create({ - from: { - type: "user", - id: user.id, - }, - body: "Welcome to the club, buddy!", - }); - - // act - const response = await client.tags.tagConversation({ - conversation_id: conversation.conversation_id, - id: tag.id, - admin_id: adminId, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/messages.test.ts b/tests/integration/messages.test.ts deleted file mode 100644 index e1bd716b..00000000 --- a/tests/integration/messages.test.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { Intercom } from "../../src"; -import { tryDeleteContact } from "./helpers"; -import { randomString } from "./utils/random"; -import { wait } from "./utils/wait"; -import { createClient } from "./utils/createClient"; - -describe("Messages", () => { - let adminId: string; - let user: Intercom.Contact; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const admins = await client.admins.list(); - const adminList = admins.admins.filter((admin) => admin.has_inbox_seat); - - adminId = adminList[0].id; - user = await client.contacts.create({ - external_id: randomString(), - name: "Message Test User", - }); - }); - - afterAll(async () => { - // cleanup - await tryDeleteContact(client, user.id); - }); - - it("Message that creates a converation", async () => { - // act - const response = await client.messages.create({ - message_type: "inapp", - body: "Hey, look at me! I am the conversations creator now!", - from: { - type: "admin", - id: Number(adminId), - }, - to: { - type: "user", - id: user.id, - }, - create_conversation_without_contact_reply: true, - }); - - const messageId = response.id; - - // Give Intercom a few seconds to index conversation - await wait(10_000); - - const searchResults = await client.conversations.search({ - query: { - field: "source.id", - operator: "=", - value: messageId, - }, - }); - - // assert - expect(searchResults.data.length).toBeGreaterThan(0); - }, 20_000); - - it("Create message, no conversation", async () => { - // act - const response = await client.messages.create({ - message_type: "inapp", - body: "Message without creating conversation", - from: { - type: "admin", - id: Number(adminId), - }, - to: { - type: "user", - id: user.id, - }, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/notes.test.ts b/tests/integration/notes.test.ts deleted file mode 100644 index b38c17ff..00000000 --- a/tests/integration/notes.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { Intercom } from "../../src"; -import { tryDeleteContact } from "./helpers"; -import { randomString } from "./utils/random"; -import { createClient } from "./utils/createClient"; - -describe("Notes", () => { - let adminId: string; - let contact: Intercom.Contact; - let note: Intercom.Note; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const admins = await client.admins.list(); - adminId = admins.admins[0].id; - - contact = await client.contacts.create({ - external_id: randomString(), - }); - - note = await client.notes.create({ - admin_id: adminId, - body: randomString(), - contact_id: contact.id, - }); - }); - - afterAll(async () => { - // cleanup - await tryDeleteContact(client, contact.id); - }); - - it("create", async () => { - // act - const response = await client.notes.create({ - admin_id: adminId, - body: randomString(), - contact_id: contact.id, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("find", async () => { - // act - const response = await client.notes.find({ note_id: note.id }); - - // assert - expect(response).toBeDefined(); - }); - - it("list", async () => { - // act - const response = await client.notes.list({ - contact_id: contact.id, - per_page: 25, - page: 1, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/pagination.test.ts b/tests/integration/pagination.test.ts deleted file mode 100644 index 07112d63..00000000 --- a/tests/integration/pagination.test.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { Companies } from "../../src/api/resources/companies/client/Client"; -import { Contacts } from "../../src/api/resources/contacts/client/Client"; -import { Conversations } from "../../src/api/resources/conversations/client/Client"; -import { Collections } from "../../src/api/resources/helpCenters/resources/collections/client/Client"; -import { Notes } from "../../src/api/resources/notes/client/Client"; -import { createClient } from "./utils/createClient"; -import { randomString } from "./utils/random"; - -type TestClient = Collections | Companies | Contacts | Conversations | Notes; - -describe("Pagination", () => { - const client = createClient(); - - interface TestCase { - name: string; - client: TestClient; - limit: number; - perPage: number; - greaterThan: number; - setup?: () => Promise; - additionalParams?: Record; - } - - const testCases: TestCase[] = [ - { - name: "helpCenters collections", - client: client.helpCenters.collections, - limit: 2, - perPage: 1, - greaterThan: 1, - }, - { - name: "companies", - client: client.companies, - limit: 10, - perPage: 1, - greaterThan: 0, - }, - { - name: "contacts", - client: client.contacts, - limit: 100, - perPage: 50, - greaterThan: 0, - }, - { - name: "conversations", - client: client.conversations, - limit: 2, - perPage: 1, - greaterThan: 1, - async setup() { - const contact = await client.contacts.create({ - external_id: randomString(), - }); - - await client.conversations.create({ - from: { id: contact.id, type: "user" }, - body: "Test conversation 1", - }); - - await client.conversations.create({ - from: { id: contact.id, type: "user" }, - body: "Test conversation 2", - }); - - return {}; - }, - }, - { - name: "notes", - client: client.notes, - limit: 2, - perPage: 1, - greaterThan: 1, - async setup() { - const contact = await client.contacts.create({ - email: `${randomString()}@test.com`, - }); - - await client.notes.create({ - contact_id: contact.id, - body: "one", - }); - - await client.notes.create({ - contact_id: contact.id, - body: "two", - }); - - return { contact_id: contact.id }; - }, - }, - ]; - - async function testIterator({ - client, - limit, - params, - }: { - client: TestClient; - limit: number; - params: Record; - }) { - const iterator = await client.list(params as any); - expect(iterator).toBeDefined(); - - let count = 0; - for await (const item of iterator) { - expect(item).toBeDefined(); - expect(item.id).toBeDefined(); - count++; - - if (count >= limit) { - break; - } - } - return count; - } - - async function testPager({ - client, - limit, - params, - }: { - client: TestClient; - limit: number; - params: Record; - }) { - const pager = await client.list(params as any); - expect(pager).toBeDefined(); - - let count = pager.data.length; - while (pager.hasNextPage()) { - await pager.getNextPage(); - count += pager.data.length; - - if (count >= limit) { - break; - } - } - return count; - } - - testCases.forEach(({ name, client, limit, perPage, greaterThan, setup, additionalParams }) => { - it(name, async () => { - let params: Record = { per_page: perPage }; - if (setup) { - const setupParams = await setup(); - params = { ...params, ...setupParams }; - } - if (additionalParams) { - params = { ...params, ...additionalParams }; - } - - const iteratorCount = await testIterator({ client, limit, params: { ...params } }); - const pagerCount = await testPager({ client, limit, params: { ...params } }); - expect(iteratorCount).toBeGreaterThan(greaterThan); - expect(pagerCount).toBeGreaterThan(greaterThan); - - // Confirm iterator and pager return same count. - expect(pagerCount).toEqual(iteratorCount); - }); - }); -}); diff --git a/tests/integration/phoneCallRedirect.test.ts b/tests/integration/phoneCallRedirect.test.ts deleted file mode 100644 index 3fc363d2..00000000 --- a/tests/integration/phoneCallRedirect.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { createClient } from "./utils/createClient"; - -describe("phoneCallRedirect", () => { - const client = createClient(); - - // TODO: Configure Twilio to enable phone call redirect tests. - it.skip("create", async () => { - // act - const response = await client.phoneCallRedirects.create({ - phone: "+353832345678", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/segments.test.ts b/tests/integration/segments.test.ts deleted file mode 100644 index 902c4c75..00000000 --- a/tests/integration/segments.test.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { createClient } from "./utils/createClient"; - -describe("Segments", () => { - let segmentId: string; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const response = await client.segments.list(); - segmentId = response.segments[0].id; - }); - - it("list", async () => { - // act - const response = await client.segments.list({ - include_count: true, - }); - - // assert - expect(response).toBeDefined(); - }); - - it("find", async () => { - // act - const response = await client.segments.find({ segment_id: segmentId }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/subscriptions.test.ts b/tests/integration/subscriptions.test.ts deleted file mode 100644 index 73b9dcb6..00000000 --- a/tests/integration/subscriptions.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createClient } from "./utils/createClient"; - -describe("Subscriptions", () => { - const client = createClient(); - - it("listTypes", async () => { - // act - const response = await client.subscriptionTypes.list(); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/tags.test.ts b/tests/integration/tags.test.ts deleted file mode 100644 index f4fa85c5..00000000 --- a/tests/integration/tags.test.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { Intercom } from "../../src"; -import { - tryDeleteTag, - createContact, - tryDeleteContact, - createConversation, - tryDeleteCompany, - createCompany, - tryUntagContact, - tryUntagConversation, - tryUntagCompany, -} from "./helpers"; -import { createClient } from "./utils/createClient"; -import { randomString } from "./utils/random"; -import { wait } from "./utils/wait"; - -describe("Tags", () => { - let adminId: string; - let tag: Intercom.Tag; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const randomAdmins = await client.admins.list(); - adminId = randomAdmins.admins[0].id; - tag = await client.tags.create({ - name: randomString(), - }); - }); - - afterAll(async () => { - // cleanup - await tryDeleteTag(client, tag.id); - }); - - it("create", async () => { - // act - const response = await client.tags.create({ - name: "Bellic and Partners", - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteTag(client, response.id); - }); - - it("update", async () => { - // arrange - const tag = await client.tags.create({ - name: randomString(), - }); - - // act - const response = await client.tags.create({ id: tag.id, name: "Poor" }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteTag(client, response.id); - }); - - it("find", async () => { - // act - const response = await client.tags.find({ tag_id: tag.id }); - - // assert - expect(response).toBeDefined(); - }); - - it("list", async () => { - // act - const response = await client.tags.list(); - - // assert - expect(response).toBeDefined(); - }); - - it("delete", async () => { - // arrange - const tag = await client.tags.create({ - name: randomString(), - }); - - // act & assert - expect(async () => await client.tags.delete({ tag_id: tag.id })).not.toThrow(); - - // cleanup - await tryDeleteTag(client, tag.id); - }); - - it("tagContact", async () => { - // arrange - const contact = await createContact(client); - - // act - const response = await client.tags.tagContact({ - contact_id: contact.id, - id: tag.id, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryUntagContact(client, contact.id, tag.id); - await tryDeleteContact(client, contact.id); - }); - - it("tagConversation", async () => { - // arrange - const contact = await createContact(client); - const message = await createConversation(client, contact.id); - - // act - const response = await client.tags.tagConversation({ - conversation_id: message.conversation_id, - id: tag.id, - admin_id: adminId, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryUntagConversation(client, message.conversation_id, tag.id, adminId); - await tryDeleteContact(client, contact.id); - }, 10_000); - - it("tagCompany", async () => { - // arrange - const company = await createCompany(client); - - // act - const response = await client.tags.create({ - name: "Poor", - companies: [{ company_id: company.company_id }], - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryUntagCompany(client, "Poor", company); - await tryDeleteCompany(client, company.id); - }); - - it("untagContact", async () => { - // arrange - const contact = await createContact(client); - await client.tags.tagContact({ - contact_id: contact.id, - id: tag.id, - }); - - // act - const response = await client.tags.untagContact({ - contact_id: contact.id, - tag_id: tag.id, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, contact.id); - }); - - it("untagConversation", async () => { - // arrange - const contact = await createContact(client); - const message = await createConversation(client, contact.id); - - await client.tags.tagConversation({ - conversation_id: message.conversation_id, - id: tag.id, - admin_id: adminId, - }); - - // act - const response = await client.tags.untagConversation({ - conversation_id: message.conversation_id, - tag_id: tag.id, - admin_id: adminId, - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteContact(client, contact.id); - }, 10_000); - - it("untagCompany", async () => { - // arrange - const company = await createCompany(client); - await client.tags.create({ - name: "Poor", - companies: [{ id: company.id, company_id: company.company_id }], - }); - - // act - const response = await client.tags.create({ - name: "Poor", - companies: [{ id: company.id, company_id: company.company_id, untag: true }], - }); - - // assert - expect(response).toBeDefined(); - - // cleanup - await tryDeleteCompany(client, company.id); - }); -}); diff --git a/tests/integration/teams.test.ts b/tests/integration/teams.test.ts deleted file mode 100644 index 59165464..00000000 --- a/tests/integration/teams.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { createClient } from "./utils/createClient"; - -describe("Teams", () => { - let teamId: string; - - const client = createClient(); - - beforeAll(async () => { - // arrange - const response = await client.teams.list(); - teamId = response.teams[0].id; - }); - - it("list", async () => { - // act - const response = await client.teams.list(); - - // assert - expect(response).toBeDefined(); - }); - - it("find", async () => { - // act - const response = await client.teams.find({ team_id: teamId }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/integration/utils/createClient.ts b/tests/integration/utils/createClient.ts deleted file mode 100644 index f2662688..00000000 --- a/tests/integration/utils/createClient.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { type Intercom, IntercomClient } from "../../../src"; - -type IntercomVersion = Intercom.IntercomVersion; - -export function createClient(options?: { version?: IntercomVersion }): IntercomClient { - const { version } = options || {}; - return new IntercomClient({ - token: process.env.API_TOKEN as string, - version, - }); -} diff --git a/tests/integration/utils/date.ts b/tests/integration/utils/date.ts deleted file mode 100644 index 4ec8b32f..00000000 --- a/tests/integration/utils/date.ts +++ /dev/null @@ -1 +0,0 @@ -export const dateToUnixTimestamp = (date: Date): number => Math.floor(date.getTime() / 1000); diff --git a/tests/integration/utils/random.ts b/tests/integration/utils/random.ts deleted file mode 100644 index 496df284..00000000 --- a/tests/integration/utils/random.ts +++ /dev/null @@ -1,6 +0,0 @@ -import crypto from "crypto"; - -export const randomString = (): string => crypto.randomBytes(16).toString("hex"); - -export const randomInt = (min = 0, max = 999): number => - Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min) + 1)) + Math.ceil(min); diff --git a/tests/integration/utils/wait.ts b/tests/integration/utils/wait.ts deleted file mode 100644 index 685944a5..00000000 --- a/tests/integration/utils/wait.ts +++ /dev/null @@ -1,3 +0,0 @@ -export async function wait(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)); -} diff --git a/tests/integration/visitors.test.ts b/tests/integration/visitors.test.ts deleted file mode 100644 index 10e2a469..00000000 --- a/tests/integration/visitors.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { createClient } from "./utils/createClient"; - -// Skip by default, because there is no automation yet -describe.skip("Visitors", () => { - // Info: should be set manually. Find a way to automate it. - // Tip: headless browser to visit test application and get visitorId from ping request. - const visitorId = "0"; - const userId = "0"; - - const client = createClient(); - - it("find by id", async () => { - // act - const response = await client.visitors.find({ user_id: visitorId }); - - // assert - expect(response).toBeDefined(); - }); - it("find by user id", async () => { - // act - const response = await client.visitors.find({ user_id: userId }); - - // assert - expect(response).toBeDefined(); - }); - it("update", async () => { - // act - const response = await client.visitors.update({ - user_id: userId, - name: "Winston Smith", - }); - - // assert - - expect(response).toBeDefined(); - }); - - it("mergeToContact", async () => { - // act - const response = await client.visitors.mergeToContact({ - visitor: { - id: visitorId, - }, - user: { - email: "mcboxford@intercom-test.com", - } as any, - type: "user", - }); - - // assert - expect(response).toBeDefined(); - }); -}); diff --git a/tests/mock-server/MockServer.ts b/tests/mock-server/MockServer.ts deleted file mode 100644 index 95487215..00000000 --- a/tests/mock-server/MockServer.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { RequestHandlerOptions } from "msw"; -import type { SetupServer } from "msw/node"; - -import { mockEndpointBuilder } from "./mockEndpointBuilder"; - -export interface MockServerOptions { - baseUrl: string; - server: SetupServer; -} - -export class MockServer { - private readonly server: SetupServer; - public readonly baseUrl: string; - - constructor({ baseUrl, server }: MockServerOptions) { - this.baseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl; - this.server = server; - } - - public mockEndpoint(options?: RequestHandlerOptions): ReturnType { - const builder = mockEndpointBuilder({ - once: options?.once ?? true, - onBuild: (handler) => { - this.server.use(handler); - }, - }).baseUrl(this.baseUrl); - return builder; - } -} diff --git a/tests/mock-server/MockServerPool.ts b/tests/mock-server/MockServerPool.ts deleted file mode 100644 index e1a90f7f..00000000 --- a/tests/mock-server/MockServerPool.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { setupServer } from "msw/node"; - -import { fromJson, toJson } from "../../src/core/json"; -import { MockServer } from "./MockServer"; -import { randomBaseUrl } from "./randomBaseUrl"; - -const mswServer = setupServer(); -interface MockServerOptions { - baseUrl?: string; -} - -async function formatHttpRequest(request: Request, id?: string): Promise { - try { - const clone = request.clone(); - const headers = [...clone.headers.entries()].map(([k, v]) => `${k}: ${v}`).join("\n"); - - let body = ""; - try { - const contentType = clone.headers.get("content-type"); - if (contentType?.includes("application/json")) { - body = toJson(fromJson(await clone.text()), undefined, 2); - } else if (clone.body) { - body = await clone.text(); - } - } catch (_e) { - body = "(unable to parse body)"; - } - - const title = id ? `### Request ${id} ###\n` : ""; - const firstLine = `${title}${request.method} ${request.url.toString()} HTTP/1.1`; - - return `\n${firstLine}\n${headers}\n\n${body || "(no body)"}\n`; - } catch (e) { - return `Error formatting request: ${e}`; - } -} - -async function formatHttpResponse(response: Response, id?: string): Promise { - try { - const clone = response.clone(); - const headers = [...clone.headers.entries()].map(([k, v]) => `${k}: ${v}`).join("\n"); - - let body = ""; - try { - const contentType = clone.headers.get("content-type"); - if (contentType?.includes("application/json")) { - body = toJson(fromJson(await clone.text()), undefined, 2); - } else if (clone.body) { - body = await clone.text(); - } - } catch (_e) { - body = "(unable to parse body)"; - } - - const title = id ? `### Response for ${id} ###\n` : ""; - const firstLine = `${title}HTTP/1.1 ${response.status} ${response.statusText}`; - - return `\n${firstLine}\n${headers}\n\n${body || "(no body)"}\n`; - } catch (e) { - return `Error formatting response: ${e}`; - } -} - -class MockServerPool { - private servers: MockServer[] = []; - - public createServer(options?: Partial): MockServer { - const baseUrl = options?.baseUrl || randomBaseUrl(); - const server = new MockServer({ baseUrl, server: mswServer }); - this.servers.push(server); - return server; - } - - public getServers(): MockServer[] { - return [...this.servers]; - } - - public listen(): void { - const onUnhandledRequest = process.env.LOG_LEVEL === "debug" ? "warn" : "bypass"; - mswServer.listen({ onUnhandledRequest }); - - if (process.env.LOG_LEVEL === "debug") { - mswServer.events.on("request:start", async ({ request, requestId }) => { - const formattedRequest = await formatHttpRequest(request, requestId); - console.debug(`request:start\n${formattedRequest}`); - }); - - mswServer.events.on("request:unhandled", async ({ request, requestId }) => { - const formattedRequest = await formatHttpRequest(request, requestId); - console.debug(`request:unhandled\n${formattedRequest}`); - }); - - mswServer.events.on("response:mocked", async ({ request, response, requestId }) => { - const formattedResponse = await formatHttpResponse(response, requestId); - console.debug(`response:mocked\n${formattedResponse}`); - }); - } - } - - public close(): void { - this.servers = []; - mswServer.close(); - } -} - -export const mockServerPool = new MockServerPool(); diff --git a/tests/mock-server/mockEndpointBuilder.ts b/tests/mock-server/mockEndpointBuilder.ts deleted file mode 100644 index 1b0e5107..00000000 --- a/tests/mock-server/mockEndpointBuilder.ts +++ /dev/null @@ -1,227 +0,0 @@ -import { type DefaultBodyType, type HttpHandler, HttpResponse, type HttpResponseResolver, http } from "msw"; - -import { url } from "../../src/core"; -import { toJson } from "../../src/core/json"; -import { withFormUrlEncoded } from "./withFormUrlEncoded"; -import { withHeaders } from "./withHeaders"; -import { withJson } from "./withJson"; - -type HttpMethod = "all" | "get" | "post" | "put" | "delete" | "patch" | "options" | "head"; - -interface MethodStage { - baseUrl(baseUrl: string): MethodStage; - all(path: string): RequestHeadersStage; - get(path: string): RequestHeadersStage; - post(path: string): RequestHeadersStage; - put(path: string): RequestHeadersStage; - delete(path: string): RequestHeadersStage; - patch(path: string): RequestHeadersStage; - options(path: string): RequestHeadersStage; - head(path: string): RequestHeadersStage; -} - -interface RequestHeadersStage extends RequestBodyStage, ResponseStage { - header(name: string, value: string): RequestHeadersStage; - headers(headers: Record): RequestBodyStage; -} - -interface RequestBodyStage extends ResponseStage { - jsonBody(body: unknown): ResponseStage; - formUrlEncodedBody(body: unknown): ResponseStage; -} - -interface ResponseStage { - respondWith(): ResponseStatusStage; -} -interface ResponseStatusStage { - statusCode(statusCode: number): ResponseHeaderStage; -} - -interface ResponseHeaderStage extends ResponseBodyStage, BuildStage { - header(name: string, value: string): ResponseHeaderStage; - headers(headers: Record): ResponseHeaderStage; -} - -interface ResponseBodyStage { - jsonBody(body: unknown): BuildStage; -} - -interface BuildStage { - build(): HttpHandler; -} - -export interface HttpHandlerBuilderOptions { - onBuild?: (handler: HttpHandler) => void; - once?: boolean; -} - -class RequestBuilder implements MethodStage, RequestHeadersStage, RequestBodyStage, ResponseStage { - private method: HttpMethod = "get"; - private _baseUrl: string = ""; - private path: string = "/"; - private readonly predicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[] = []; - private readonly handlerOptions?: HttpHandlerBuilderOptions; - - constructor(options?: HttpHandlerBuilderOptions) { - this.handlerOptions = options; - } - - baseUrl(baseUrl: string): MethodStage { - this._baseUrl = baseUrl; - return this; - } - - all(path: string): RequestHeadersStage { - this.method = "all"; - this.path = path; - return this; - } - - get(path: string): RequestHeadersStage { - this.method = "get"; - this.path = path; - return this; - } - - post(path: string): RequestHeadersStage { - this.method = "post"; - this.path = path; - return this; - } - - put(path: string): RequestHeadersStage { - this.method = "put"; - this.path = path; - return this; - } - - delete(path: string): RequestHeadersStage { - this.method = "delete"; - this.path = path; - return this; - } - - patch(path: string): RequestHeadersStage { - this.method = "patch"; - this.path = path; - return this; - } - - options(path: string): RequestHeadersStage { - this.method = "options"; - this.path = path; - return this; - } - - head(path: string): RequestHeadersStage { - this.method = "head"; - this.path = path; - return this; - } - - header(name: string, value: string): RequestHeadersStage { - this.predicates.push((resolver) => withHeaders({ [name]: value }, resolver)); - return this; - } - - headers(headers: Record): RequestBodyStage { - this.predicates.push((resolver) => withHeaders(headers, resolver)); - return this; - } - - jsonBody(body: unknown): ResponseStage { - if (body === undefined) { - throw new Error("Undefined is not valid JSON. Do not call jsonBody if you want an empty body."); - } - this.predicates.push((resolver) => withJson(body, resolver)); - return this; - } - - formUrlEncodedBody(body: unknown): ResponseStage { - if (body === undefined) { - throw new Error( - "Undefined is not valid for form-urlencoded. Do not call formUrlEncodedBody if you want an empty body.", - ); - } - this.predicates.push((resolver) => withFormUrlEncoded(body, resolver)); - return this; - } - - respondWith(): ResponseStatusStage { - return new ResponseBuilder(this.method, this.buildUrl(), this.predicates, this.handlerOptions); - } - - private buildUrl(): string { - return url.join(this._baseUrl, this.path); - } -} - -class ResponseBuilder implements ResponseStatusStage, ResponseHeaderStage, ResponseBodyStage, BuildStage { - private readonly method: HttpMethod; - private readonly url: string; - private readonly requestPredicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[]; - private readonly handlerOptions?: HttpHandlerBuilderOptions; - - private responseStatusCode: number = 200; - private responseHeaders: Record = {}; - private responseBody: DefaultBodyType = undefined; - - constructor( - method: HttpMethod, - url: string, - requestPredicates: ((resolver: HttpResponseResolver) => HttpResponseResolver)[], - options?: HttpHandlerBuilderOptions, - ) { - this.method = method; - this.url = url; - this.requestPredicates = requestPredicates; - this.handlerOptions = options; - } - - public statusCode(code: number): ResponseHeaderStage { - this.responseStatusCode = code; - return this; - } - - public header(name: string, value: string): ResponseHeaderStage { - this.responseHeaders[name] = value; - return this; - } - - public headers(headers: Record): ResponseHeaderStage { - this.responseHeaders = { ...this.responseHeaders, ...headers }; - return this; - } - - public jsonBody(body: unknown): BuildStage { - if (body === undefined) { - throw new Error("Undefined is not valid JSON. Do not call jsonBody if you expect an empty body."); - } - this.responseBody = toJson(body); - return this; - } - - public build(): HttpHandler { - const responseResolver: HttpResponseResolver = () => { - const response = new HttpResponse(this.responseBody, { - status: this.responseStatusCode, - headers: this.responseHeaders, - }); - // if no Content-Type header is set, delete the default text content type that is set - if (Object.keys(this.responseHeaders).some((key) => key.toLowerCase() === "content-type") === false) { - response.headers.delete("Content-Type"); - } - return response; - }; - - const finalResolver = this.requestPredicates.reduceRight((acc, predicate) => predicate(acc), responseResolver); - - const handler = http[this.method](this.url, finalResolver, this.handlerOptions); - this.handlerOptions?.onBuild?.(handler); - return handler; - } -} - -export function mockEndpointBuilder(options?: HttpHandlerBuilderOptions): MethodStage { - return new RequestBuilder(options); -} diff --git a/tests/mock-server/randomBaseUrl.ts b/tests/mock-server/randomBaseUrl.ts deleted file mode 100644 index 031aa640..00000000 --- a/tests/mock-server/randomBaseUrl.ts +++ /dev/null @@ -1,4 +0,0 @@ -export function randomBaseUrl(): string { - const randomString = Math.random().toString(36).substring(2, 15); - return `http://${randomString}.localhost`; -} diff --git a/tests/mock-server/setup.ts b/tests/mock-server/setup.ts deleted file mode 100644 index aeb3a95a..00000000 --- a/tests/mock-server/setup.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { afterAll, beforeAll } from "vitest"; - -import { mockServerPool } from "./MockServerPool"; - -beforeAll(() => { - mockServerPool.listen(); -}); -afterAll(() => { - mockServerPool.close(); -}); diff --git a/tests/mock-server/withFormUrlEncoded.ts b/tests/mock-server/withFormUrlEncoded.ts deleted file mode 100644 index e9e6ff2d..00000000 --- a/tests/mock-server/withFormUrlEncoded.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { type HttpResponseResolver, passthrough } from "msw"; - -import { toJson } from "../../src/core/json"; - -/** - * Creates a request matcher that validates if the request form-urlencoded body exactly matches the expected object - * @param expectedBody - The exact body object to match against - * @param resolver - Response resolver to execute if body matches - */ -export function withFormUrlEncoded(expectedBody: unknown, resolver: HttpResponseResolver): HttpResponseResolver { - return async (args) => { - const { request } = args; - - let clonedRequest: Request; - let bodyText: string | undefined; - let actualBody: Record; - try { - clonedRequest = request.clone(); - bodyText = await clonedRequest.text(); - if (bodyText === "") { - console.error("Request body is empty, expected a form-urlencoded body."); - return passthrough(); - } - const params = new URLSearchParams(bodyText); - actualBody = {}; - for (const [key, value] of params.entries()) { - actualBody[key] = value; - } - } catch (error) { - console.error(`Error processing form-urlencoded request body:\n\tError: ${error}\n\tBody: ${bodyText}`); - return passthrough(); - } - - const mismatches = findMismatches(actualBody, expectedBody); - if (Object.keys(mismatches).length > 0) { - console.error("Form-urlencoded body mismatch:", toJson(mismatches, undefined, 2)); - return passthrough(); - } - - return resolver(args); - }; -} - -function findMismatches(actual: any, expected: any): Record { - const mismatches: Record = {}; - - if (typeof actual !== typeof expected) { - return { value: { actual, expected } }; - } - - if (typeof actual !== "object" || actual === null || expected === null) { - if (actual !== expected) { - return { value: { actual, expected } }; - } - return {}; - } - - const actualKeys = Object.keys(actual); - const expectedKeys = Object.keys(expected); - - const allKeys = new Set([...actualKeys, ...expectedKeys]); - - for (const key of allKeys) { - if (!expectedKeys.includes(key)) { - if (actual[key] === undefined) { - continue; - } - mismatches[key] = { actual: actual[key], expected: undefined }; - } else if (!actualKeys.includes(key)) { - if (expected[key] === undefined) { - continue; - } - mismatches[key] = { actual: undefined, expected: expected[key] }; - } else if (actual[key] !== expected[key]) { - mismatches[key] = { actual: actual[key], expected: expected[key] }; - } - } - - return mismatches; -} diff --git a/tests/mock-server/withHeaders.ts b/tests/mock-server/withHeaders.ts deleted file mode 100644 index 6599d2b4..00000000 --- a/tests/mock-server/withHeaders.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { type HttpResponseResolver, passthrough } from "msw"; - -/** - * Creates a request matcher that validates if request headers match specified criteria - * @param expectedHeaders - Headers to match against - * @param resolver - Response resolver to execute if headers match - */ -export function withHeaders( - expectedHeaders: Record boolean)>, - resolver: HttpResponseResolver, -): HttpResponseResolver { - return (args) => { - const { request } = args; - const { headers } = request; - - const mismatches: Record< - string, - { actual: string | null; expected: string | RegExp | ((value: string) => boolean) } - > = {}; - - for (const [key, expectedValue] of Object.entries(expectedHeaders)) { - const actualValue = headers.get(key); - - if (actualValue === null) { - mismatches[key] = { actual: null, expected: expectedValue }; - continue; - } - - if (typeof expectedValue === "function") { - if (!expectedValue(actualValue)) { - mismatches[key] = { actual: actualValue, expected: expectedValue }; - } - } else if (expectedValue instanceof RegExp) { - if (!expectedValue.test(actualValue)) { - mismatches[key] = { actual: actualValue, expected: expectedValue }; - } - } else if (expectedValue !== actualValue) { - mismatches[key] = { actual: actualValue, expected: expectedValue }; - } - } - - if (Object.keys(mismatches).length > 0) { - const formattedMismatches = formatHeaderMismatches(mismatches); - console.error("Header mismatch:", formattedMismatches); - return passthrough(); - } - - return resolver(args); - }; -} - -function formatHeaderMismatches( - mismatches: Record boolean) }>, -): Record { - const formatted: Record = {}; - - for (const [key, { actual, expected }] of Object.entries(mismatches)) { - formatted[key] = { - actual, - expected: - expected instanceof RegExp - ? expected.toString() - : typeof expected === "function" - ? "[Function]" - : expected, - }; - } - - return formatted; -} diff --git a/tests/mock-server/withJson.ts b/tests/mock-server/withJson.ts deleted file mode 100644 index b627638b..00000000 --- a/tests/mock-server/withJson.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { type HttpResponseResolver, passthrough } from "msw"; - -import { fromJson, toJson } from "../../src/core/json"; - -/** - * Creates a request matcher that validates if the request JSON body exactly matches the expected object - * @param expectedBody - The exact body object to match against - * @param resolver - Response resolver to execute if body matches - */ -export function withJson(expectedBody: unknown, resolver: HttpResponseResolver): HttpResponseResolver { - return async (args) => { - const { request } = args; - - let clonedRequest: Request; - let bodyText: string | undefined; - let actualBody: unknown; - try { - clonedRequest = request.clone(); - bodyText = await clonedRequest.text(); - if (bodyText === "") { - console.error("Request body is empty, expected a JSON object."); - return passthrough(); - } - actualBody = fromJson(bodyText); - } catch (error) { - console.error(`Error processing request body:\n\tError: ${error}\n\tBody: ${bodyText}`); - return passthrough(); - } - - const mismatches = findMismatches(actualBody, expectedBody); - if (Object.keys(mismatches).filter((key) => !key.startsWith("pagination.")).length > 0) { - console.error("JSON body mismatch:", toJson(mismatches, undefined, 2)); - return passthrough(); - } - - return resolver(args); - }; -} - -function findMismatches(actual: any, expected: any): Record { - const mismatches: Record = {}; - - if (typeof actual !== typeof expected) { - if (areEquivalent(actual, expected)) { - return {}; - } - return { value: { actual, expected } }; - } - - if (typeof actual !== "object" || actual === null || expected === null) { - if (actual !== expected) { - if (areEquivalent(actual, expected)) { - return {}; - } - return { value: { actual, expected } }; - } - return {}; - } - - if (Array.isArray(actual) && Array.isArray(expected)) { - if (actual.length !== expected.length) { - return { length: { actual: actual.length, expected: expected.length } }; - } - - const arrayMismatches: Record = {}; - for (let i = 0; i < actual.length; i++) { - const itemMismatches = findMismatches(actual[i], expected[i]); - if (Object.keys(itemMismatches).length > 0) { - for (const [mismatchKey, mismatchValue] of Object.entries(itemMismatches)) { - arrayMismatches[`[${i}]${mismatchKey === "value" ? "" : `.${mismatchKey}`}`] = mismatchValue; - } - } - } - return arrayMismatches; - } - - const actualKeys = Object.keys(actual); - const expectedKeys = Object.keys(expected); - - const allKeys = new Set([...actualKeys, ...expectedKeys]); - - for (const key of allKeys) { - if (!expectedKeys.includes(key)) { - if (actual[key] === undefined) { - continue; // Skip undefined values in actual - } - mismatches[key] = { actual: actual[key], expected: undefined }; - } else if (!actualKeys.includes(key)) { - if (expected[key] === undefined) { - continue; // Skip undefined values in expected - } - mismatches[key] = { actual: undefined, expected: expected[key] }; - } else if ( - typeof actual[key] === "object" && - actual[key] !== null && - typeof expected[key] === "object" && - expected[key] !== null - ) { - const nestedMismatches = findMismatches(actual[key], expected[key]); - if (Object.keys(nestedMismatches).length > 0) { - for (const [nestedKey, nestedValue] of Object.entries(nestedMismatches)) { - mismatches[`${key}${nestedKey === "value" ? "" : `.${nestedKey}`}`] = nestedValue; - } - } - } else if (actual[key] !== expected[key]) { - if (areEquivalent(actual[key], expected[key])) { - continue; - } - mismatches[key] = { actual: actual[key], expected: expected[key] }; - } - } - - return mismatches; -} - -function areEquivalent(actual: unknown, expected: unknown): boolean { - if (actual === expected) { - return true; - } - if (isEquivalentBigInt(actual, expected)) { - return true; - } - if (isEquivalentDatetime(actual, expected)) { - return true; - } - return false; -} - -function isEquivalentBigInt(actual: unknown, expected: unknown) { - if (typeof actual === "number") { - actual = BigInt(actual); - } - if (typeof expected === "number") { - expected = BigInt(expected); - } - if (typeof actual === "bigint" && typeof expected === "bigint") { - return actual === expected; - } - return false; -} - -function isEquivalentDatetime(str1: unknown, str2: unknown): boolean { - if (typeof str1 !== "string" || typeof str2 !== "string") { - return false; - } - const isoDatePattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/; - if (!isoDatePattern.test(str1) || !isoDatePattern.test(str2)) { - return false; - } - - try { - const date1 = new Date(str1).getTime(); - const date2 = new Date(str2).getTime(); - return date1 === date2; - } catch { - return false; - } -} diff --git a/tests/responses.test.ts b/tests/responses.test.ts new file mode 100644 index 00000000..fa67b601 --- /dev/null +++ b/tests/responses.test.ts @@ -0,0 +1,25 @@ +import { createResponseHeaders } from 'intercom-client/core'; +import { Headers } from 'intercom-client/_shims/index'; + +describe('response parsing', () => { + // TODO: test unicode characters + test('headers are case agnostic', async () => { + const headers = createResponseHeaders(new Headers({ 'Content-Type': 'foo', Accept: 'text/plain' })); + expect(headers['content-type']).toEqual('foo'); + expect(headers['Content-type']).toEqual('foo'); + expect(headers['Content-Type']).toEqual('foo'); + expect(headers['accept']).toEqual('text/plain'); + expect(headers['Accept']).toEqual('text/plain'); + expect(headers['Hello-World']).toBeUndefined(); + }); + + test('duplicate headers are concatenated', () => { + const headers = createResponseHeaders( + new Headers([ + ['Content-Type', 'text/xml'], + ['Content-Type', 'application/json'], + ]), + ); + expect(headers['content-type']).toBe('text/xml, application/json'); + }); +}); diff --git a/tests/setup.ts b/tests/setup.ts deleted file mode 100644 index a5651f81..00000000 --- a/tests/setup.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { expect } from "vitest"; - -interface CustomMatchers { - toContainHeaders(expectedHeaders: Record): R; -} - -declare module "vitest" { - interface Assertion extends CustomMatchers {} - interface AsymmetricMatchersContaining extends CustomMatchers {} -} - -expect.extend({ - toContainHeaders(actual: unknown, expectedHeaders: Record) { - const isHeaders = actual instanceof Headers; - const isPlainObject = typeof actual === "object" && actual !== null && !Array.isArray(actual); - - if (!isHeaders && !isPlainObject) { - throw new TypeError("Received value must be an instance of Headers or a plain object!"); - } - - if (typeof expectedHeaders !== "object" || expectedHeaders === null || Array.isArray(expectedHeaders)) { - throw new TypeError("Expected headers must be a plain object!"); - } - - const missingHeaders: string[] = []; - const mismatchedHeaders: Array<{ key: string; expected: string; actual: string | null }> = []; - - for (const [key, value] of Object.entries(expectedHeaders)) { - let actualValue: string | null = null; - - if (isHeaders) { - // Headers.get() is already case-insensitive - actualValue = (actual as Headers).get(key); - } else { - // For plain objects, do case-insensitive lookup - const actualObj = actual as Record; - const lowerKey = key.toLowerCase(); - const foundKey = Object.keys(actualObj).find((k) => k.toLowerCase() === lowerKey); - actualValue = foundKey ? actualObj[foundKey] : null; - } - - if (actualValue === null || actualValue === undefined) { - missingHeaders.push(key); - } else if (actualValue !== value) { - mismatchedHeaders.push({ key, expected: value, actual: actualValue }); - } - } - - const pass = missingHeaders.length === 0 && mismatchedHeaders.length === 0; - - const actualType = isHeaders ? "Headers" : "object"; - - if (pass) { - return { - message: () => `expected ${actualType} not to contain ${this.utils.printExpected(expectedHeaders)}`, - pass: true, - }; - } else { - const messages: string[] = []; - - if (missingHeaders.length > 0) { - messages.push(`Missing headers: ${this.utils.printExpected(missingHeaders.join(", "))}`); - } - - if (mismatchedHeaders.length > 0) { - const mismatches = mismatchedHeaders.map( - ({ key, expected, actual }) => - `${key}: expected ${this.utils.printExpected(expected)} but got ${this.utils.printReceived(actual)}`, - ); - messages.push(mismatches.join("\n")); - } - - return { - message: () => - `expected ${actualType} to contain ${this.utils.printExpected(expectedHeaders)}\n\n${messages.join("\n")}`, - pass: false, - }; - } - }, -}); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts new file mode 100644 index 00000000..2fc9c1b1 --- /dev/null +++ b/tests/stringifyQuery.test.ts @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { Intercom } from 'intercom-client'; + +const { stringifyQuery } = Intercom.prototype as any; + +describe(stringifyQuery, () => { + for (const [input, expected] of [ + [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], + [{ a: null, b: false, c: undefined }, 'a=&b=false'], + [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], + [ + { 'a/b': 'c/d', 'e=f': 'g&h' }, + `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( + 'e=f', + )}=${encodeURIComponent('g&h')}`, + ], + ]) { + it(`${JSON.stringify(input)} -> ${expected}`, () => { + expect(stringifyQuery(input)).toEqual(expected); + }); + } +}); diff --git a/tests/tsconfig.json b/tests/tsconfig.json deleted file mode 100644 index a477df47..00000000 --- a/tests/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": null, - "rootDir": "..", - "baseUrl": "..", - "types": ["vitest/globals"] - }, - "include": ["../src", "../tests"], - "exclude": [] -} diff --git a/tests/unit/auth/BasicAuth.test.ts b/tests/unit/auth/BasicAuth.test.ts deleted file mode 100644 index 9b512336..00000000 --- a/tests/unit/auth/BasicAuth.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { BasicAuth } from "../../../src/core/auth/BasicAuth"; - -describe("BasicAuth", () => { - interface ToHeaderTestCase { - description: string; - input: { username: string; password: string }; - expected: string; - } - - interface FromHeaderTestCase { - description: string; - input: string; - expected: { username: string; password: string }; - } - - interface ErrorTestCase { - description: string; - input: string; - expectedError: string; - } - - describe("toAuthorizationHeader", () => { - const toHeaderTests: ToHeaderTestCase[] = [ - { - description: "correctly converts to header", - input: { username: "username", password: "password" }, - expected: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - }, - ]; - - toHeaderTests.forEach(({ description, input, expected }) => { - it(description, () => { - expect(BasicAuth.toAuthorizationHeader(input)).toBe(expected); - }); - }); - }); - - describe("fromAuthorizationHeader", () => { - const fromHeaderTests: FromHeaderTestCase[] = [ - { - description: "correctly parses header", - input: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - expected: { username: "username", password: "password" }, - }, - { - description: "handles password with colons", - input: "Basic dXNlcjpwYXNzOndvcmQ=", - expected: { username: "user", password: "pass:word" }, - }, - { - description: "handles empty username and password (just colon)", - input: "Basic Og==", - expected: { username: "", password: "" }, - }, - { - description: "handles empty username", - input: "Basic OnBhc3N3b3Jk", - expected: { username: "", password: "password" }, - }, - { - description: "handles empty password", - input: "Basic dXNlcm5hbWU6", - expected: { username: "username", password: "" }, - }, - ]; - - fromHeaderTests.forEach(({ description, input, expected }) => { - it(description, () => { - expect(BasicAuth.fromAuthorizationHeader(input)).toEqual(expected); - }); - }); - - const errorTests: ErrorTestCase[] = [ - { - description: "throws error for completely empty credentials", - input: "Basic ", - expectedError: "Invalid basic auth", - }, - { - description: "throws error for credentials without colon", - input: "Basic dXNlcm5hbWU=", - expectedError: "Invalid basic auth", - }, - ]; - - errorTests.forEach(({ description, input, expectedError }) => { - it(description, () => { - expect(() => BasicAuth.fromAuthorizationHeader(input)).toThrow(expectedError); - }); - }); - }); -}); diff --git a/tests/unit/auth/BearerToken.test.ts b/tests/unit/auth/BearerToken.test.ts deleted file mode 100644 index 7757b87c..00000000 --- a/tests/unit/auth/BearerToken.test.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BearerToken } from "../../../src/core/auth/BearerToken"; - -describe("BearerToken", () => { - describe("toAuthorizationHeader", () => { - it("correctly converts to header", () => { - expect(BearerToken.toAuthorizationHeader("my-token")).toBe("Bearer my-token"); - }); - }); - describe("fromAuthorizationHeader", () => { - it("correctly parses header", () => { - expect(BearerToken.fromAuthorizationHeader("Bearer my-token")).toBe("my-token"); - }); - }); -}); diff --git a/tests/unit/base64.test.ts b/tests/unit/base64.test.ts deleted file mode 100644 index 939594ca..00000000 --- a/tests/unit/base64.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { base64Decode, base64Encode } from "../../src/core/base64"; - -describe("base64", () => { - describe("base64Encode", () => { - it("should encode ASCII strings", () => { - expect(base64Encode("hello")).toBe("aGVsbG8="); - expect(base64Encode("")).toBe(""); - }); - - it("should encode UTF-8 strings", () => { - expect(base64Encode("café")).toBe("Y2Fmw6k="); - expect(base64Encode("🎉")).toBe("8J+OiQ=="); - }); - - it("should handle basic auth credentials", () => { - expect(base64Encode("username:password")).toBe("dXNlcm5hbWU6cGFzc3dvcmQ="); - }); - }); - - describe("base64Decode", () => { - it("should decode ASCII strings", () => { - expect(base64Decode("aGVsbG8=")).toBe("hello"); - expect(base64Decode("")).toBe(""); - }); - - it("should decode UTF-8 strings", () => { - expect(base64Decode("Y2Fmw6k=")).toBe("café"); - expect(base64Decode("8J+OiQ==")).toBe("🎉"); - }); - - it("should handle basic auth credentials", () => { - expect(base64Decode("dXNlcm5hbWU6cGFzc3dvcmQ=")).toBe("username:password"); - }); - }); - - describe("round-trip encoding", () => { - const testStrings = [ - "hello world", - "test@example.com", - "café", - "username:password", - "user@domain.com:super$ecret123!", - ]; - - testStrings.forEach((testString) => { - it(`should round-trip encode/decode: "${testString}"`, () => { - const encoded = base64Encode(testString); - const decoded = base64Decode(encoded); - expect(decoded).toBe(testString); - }); - }); - }); -}); diff --git a/tests/unit/fetcher/Fetcher.test.ts b/tests/unit/fetcher/Fetcher.test.ts deleted file mode 100644 index 60df2b5e..00000000 --- a/tests/unit/fetcher/Fetcher.test.ts +++ /dev/null @@ -1,261 +0,0 @@ -import fs from "fs"; -import { join } from "path"; -import stream from "stream"; -import type { BinaryResponse } from "../../../src/core"; -import { type Fetcher, fetcherImpl } from "../../../src/core/fetcher/Fetcher"; - -describe("Test fetcherImpl", () => { - it("should handle successful request", async () => { - const mockArgs: Fetcher.Args = { - url: "https://httpbin.org/post", - method: "POST", - headers: { "X-Test": "x-test-header" }, - body: { data: "test" }, - contentType: "application/json", - requestType: "json", - maxRetries: 0, - responseType: "json", - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify({ data: "test" }), { - status: 200, - statusText: "OK", - }), - ); - - const result = await fetcherImpl(mockArgs); - expect(result.ok).toBe(true); - if (result.ok) { - expect(result.body).toEqual({ data: "test" }); - } - - expect(global.fetch).toHaveBeenCalledWith( - "https://httpbin.org/post", - expect.objectContaining({ - method: "POST", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - body: JSON.stringify({ data: "test" }), - }), - ); - }); - - it("should send octet stream", async () => { - const url = "https://httpbin.org/post/file"; - const mockArgs: Fetcher.Args = { - url, - method: "POST", - headers: { "X-Test": "x-test-header" }, - contentType: "application/octet-stream", - requestType: "bytes", - maxRetries: 0, - responseType: "json", - body: fs.createReadStream(join(__dirname, "test-file.txt")), - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify({ data: "test" }), { - status: 200, - statusText: "OK", - }), - ); - - const result = await fetcherImpl(mockArgs); - - expect(global.fetch).toHaveBeenCalledWith( - url, - expect.objectContaining({ - method: "POST", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - body: expect.any(fs.ReadStream), - }), - ); - expect(result.ok).toBe(true); - if (result.ok) { - expect(result.body).toEqual({ data: "test" }); - } - }); - - it("should receive file as stream", async () => { - const url = "https://httpbin.org/post/file"; - const mockArgs: Fetcher.Args = { - url, - method: "GET", - headers: { "X-Test": "x-test-header" }, - maxRetries: 0, - responseType: "binary-response", - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response( - stream.Readable.toWeb(fs.createReadStream(join(__dirname, "test-file.txt"))) as ReadableStream, - { - status: 200, - statusText: "OK", - }, - ), - ); - - const result = await fetcherImpl(mockArgs); - - expect(global.fetch).toHaveBeenCalledWith( - url, - expect.objectContaining({ - method: "GET", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - }), - ); - expect(result.ok).toBe(true); - if (result.ok) { - const body = result.body as BinaryResponse; - expect(body).toBeDefined(); - expect(body.bodyUsed).toBe(false); - expect(typeof body.stream).toBe("function"); - const stream = body.stream(); - expect(stream).toBeInstanceOf(ReadableStream); - const reader = stream.getReader(); - const { value } = await reader.read(); - const decoder = new TextDecoder(); - const streamContent = decoder.decode(value); - expect(streamContent).toBe("This is a test file!\n"); - expect(body.bodyUsed).toBe(true); - } - }); - - it("should receive file as blob", async () => { - const url = "https://httpbin.org/post/file"; - const mockArgs: Fetcher.Args = { - url, - method: "GET", - headers: { "X-Test": "x-test-header" }, - maxRetries: 0, - responseType: "binary-response", - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response( - stream.Readable.toWeb(fs.createReadStream(join(__dirname, "test-file.txt"))) as ReadableStream, - { - status: 200, - statusText: "OK", - }, - ), - ); - - const result = await fetcherImpl(mockArgs); - - expect(global.fetch).toHaveBeenCalledWith( - url, - expect.objectContaining({ - method: "GET", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - }), - ); - expect(result.ok).toBe(true); - if (result.ok) { - const body = result.body as BinaryResponse; - expect(body).toBeDefined(); - expect(body.bodyUsed).toBe(false); - expect(typeof body.blob).toBe("function"); - const blob = await body.blob(); - expect(blob).toBeInstanceOf(Blob); - const reader = blob.stream().getReader(); - const { value } = await reader.read(); - const decoder = new TextDecoder(); - const streamContent = decoder.decode(value); - expect(streamContent).toBe("This is a test file!\n"); - expect(body.bodyUsed).toBe(true); - } - }); - - it("should receive file as arraybuffer", async () => { - const url = "https://httpbin.org/post/file"; - const mockArgs: Fetcher.Args = { - url, - method: "GET", - headers: { "X-Test": "x-test-header" }, - maxRetries: 0, - responseType: "binary-response", - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response( - stream.Readable.toWeb(fs.createReadStream(join(__dirname, "test-file.txt"))) as ReadableStream, - { - status: 200, - statusText: "OK", - }, - ), - ); - - const result = await fetcherImpl(mockArgs); - - expect(global.fetch).toHaveBeenCalledWith( - url, - expect.objectContaining({ - method: "GET", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - }), - ); - expect(result.ok).toBe(true); - if (result.ok) { - const body = result.body as BinaryResponse; - expect(body).toBeDefined(); - expect(body.bodyUsed).toBe(false); - expect(typeof body.arrayBuffer).toBe("function"); - const arrayBuffer = await body.arrayBuffer(); - expect(arrayBuffer).toBeInstanceOf(ArrayBuffer); - const decoder = new TextDecoder(); - const streamContent = decoder.decode(new Uint8Array(arrayBuffer)); - expect(streamContent).toBe("This is a test file!\n"); - expect(body.bodyUsed).toBe(true); - } - }); - - it("should receive file as bytes", async () => { - const url = "https://httpbin.org/post/file"; - const mockArgs: Fetcher.Args = { - url, - method: "GET", - headers: { "X-Test": "x-test-header" }, - maxRetries: 0, - responseType: "binary-response", - }; - - global.fetch = vi.fn().mockResolvedValue( - new Response( - stream.Readable.toWeb(fs.createReadStream(join(__dirname, "test-file.txt"))) as ReadableStream, - { - status: 200, - statusText: "OK", - }, - ), - ); - - const result = await fetcherImpl(mockArgs); - - expect(global.fetch).toHaveBeenCalledWith( - url, - expect.objectContaining({ - method: "GET", - headers: expect.toContainHeaders({ "X-Test": "x-test-header" }), - }), - ); - expect(result.ok).toBe(true); - if (result.ok) { - const body = result.body as BinaryResponse; - expect(body).toBeDefined(); - expect(body.bodyUsed).toBe(false); - expect(typeof body.bytes).toBe("function"); - if (!body.bytes) { - return; - } - const bytes = await body.bytes(); - expect(bytes).toBeInstanceOf(Uint8Array); - const decoder = new TextDecoder(); - const streamContent = decoder.decode(bytes); - expect(streamContent).toBe("This is a test file!\n"); - expect(body.bodyUsed).toBe(true); - } - }); -}); diff --git a/tests/unit/fetcher/HttpResponsePromise.test.ts b/tests/unit/fetcher/HttpResponsePromise.test.ts deleted file mode 100644 index 2ec008e5..00000000 --- a/tests/unit/fetcher/HttpResponsePromise.test.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; - -import { HttpResponsePromise } from "../../../src/core/fetcher/HttpResponsePromise"; -import type { 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 = vi - .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 = vi.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 = vi.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 deleted file mode 100644 index 375ee3f3..00000000 --- a/tests/unit/fetcher/RawResponse.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { describe, expect, it } from "vitest"; - -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/createRequestUrl.test.ts b/tests/unit/fetcher/createRequestUrl.test.ts deleted file mode 100644 index a92f1b5e..00000000 --- a/tests/unit/fetcher/createRequestUrl.test.ts +++ /dev/null @@ -1,163 +0,0 @@ -import { createRequestUrl } from "../../../src/core/fetcher/createRequestUrl"; - -describe("Test createRequestUrl", () => { - const BASE_URL = "https://api.example.com"; - - interface TestCase { - description: string; - baseUrl: string; - queryParams?: Record; - expected: string; - } - - const testCases: TestCase[] = [ - { - description: "should return the base URL when no query parameters are provided", - baseUrl: BASE_URL, - expected: BASE_URL, - }, - { - description: "should append simple query parameters", - baseUrl: BASE_URL, - queryParams: { key: "value", another: "param" }, - expected: "https://api.example.com?key=value&another=param", - }, - { - description: "should handle array query parameters", - baseUrl: BASE_URL, - queryParams: { items: ["a", "b", "c"] }, - expected: "https://api.example.com?items=a&items=b&items=c", - }, - { - description: "should handle object query parameters", - baseUrl: BASE_URL, - queryParams: { filter: { name: "John", age: 30 } }, - expected: "https://api.example.com?filter%5Bname%5D=John&filter%5Bage%5D=30", - }, - { - description: "should handle mixed types of query parameters", - baseUrl: BASE_URL, - queryParams: { - simple: "value", - array: ["x", "y"], - object: { key: "value" }, - }, - expected: "https://api.example.com?simple=value&array=x&array=y&object%5Bkey%5D=value", - }, - { - description: "should handle empty query parameters object", - baseUrl: BASE_URL, - queryParams: {}, - expected: BASE_URL, - }, - { - description: "should encode special characters in query parameters", - baseUrl: BASE_URL, - queryParams: { special: "a&b=c d" }, - expected: "https://api.example.com?special=a%26b%3Dc%20d", - }, - { - description: "should handle numeric values", - baseUrl: BASE_URL, - queryParams: { count: 42, price: 19.99, active: 1, inactive: 0 }, - expected: "https://api.example.com?count=42&price=19.99&active=1&inactive=0", - }, - { - description: "should handle boolean values", - baseUrl: BASE_URL, - queryParams: { enabled: true, disabled: false }, - expected: "https://api.example.com?enabled=true&disabled=false", - }, - { - description: "should handle null and undefined values", - baseUrl: BASE_URL, - queryParams: { - valid: "value", - nullValue: null, - undefinedValue: undefined, - emptyString: "", - }, - expected: "https://api.example.com?valid=value&nullValue=&emptyString=", - }, - { - description: "should handle deeply nested objects", - baseUrl: BASE_URL, - queryParams: { - user: { - profile: { - name: "John", - settings: { theme: "dark" }, - }, - }, - }, - expected: - "https://api.example.com?user%5Bprofile%5D%5Bname%5D=John&user%5Bprofile%5D%5Bsettings%5D%5Btheme%5D=dark", - }, - { - description: "should handle arrays of objects", - baseUrl: BASE_URL, - queryParams: { - users: [ - { name: "John", age: 30 }, - { name: "Jane", age: 25 }, - ], - }, - expected: - "https://api.example.com?users%5Bname%5D=John&users%5Bage%5D=30&users%5Bname%5D=Jane&users%5Bage%5D=25", - }, - { - description: "should handle mixed arrays", - baseUrl: BASE_URL, - queryParams: { - mixed: ["string", 42, true, { key: "value" }], - }, - expected: "https://api.example.com?mixed=string&mixed=42&mixed=true&mixed%5Bkey%5D=value", - }, - { - description: "should handle empty arrays", - baseUrl: BASE_URL, - queryParams: { emptyArray: [] }, - expected: BASE_URL, - }, - { - description: "should handle empty objects", - baseUrl: BASE_URL, - queryParams: { emptyObject: {} }, - expected: BASE_URL, - }, - { - description: "should handle special characters in keys", - baseUrl: BASE_URL, - queryParams: { "key with spaces": "value", "key[with]brackets": "value" }, - expected: "https://api.example.com?key%20with%20spaces=value&key%5Bwith%5Dbrackets=value", - }, - { - description: "should handle URL with existing query parameters", - baseUrl: "https://api.example.com?existing=param", - queryParams: { new: "value" }, - expected: "https://api.example.com?existing=param?new=value", - }, - { - description: "should handle complex nested structures", - baseUrl: BASE_URL, - queryParams: { - filters: { - status: ["active", "pending"], - category: { - type: "electronics", - subcategories: ["phones", "laptops"], - }, - }, - sort: { field: "name", direction: "asc" }, - }, - expected: - "https://api.example.com?filters%5Bstatus%5D=active&filters%5Bstatus%5D=pending&filters%5Bcategory%5D%5Btype%5D=electronics&filters%5Bcategory%5D%5Bsubcategories%5D=phones&filters%5Bcategory%5D%5Bsubcategories%5D=laptops&sort%5Bfield%5D=name&sort%5Bdirection%5D=asc", - }, - ]; - - testCases.forEach(({ description, baseUrl, queryParams, expected }) => { - it(description, () => { - expect(createRequestUrl(baseUrl, queryParams)).toBe(expected); - }); - }); -}); diff --git a/tests/unit/fetcher/getRequestBody.test.ts b/tests/unit/fetcher/getRequestBody.test.ts deleted file mode 100644 index 8a6c3a57..00000000 --- a/tests/unit/fetcher/getRequestBody.test.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { getRequestBody } from "../../../src/core/fetcher/getRequestBody"; -import { RUNTIME } from "../../../src/core/runtime"; - -describe("Test getRequestBody", () => { - interface TestCase { - description: string; - input: any; - type: "json" | "form" | "file" | "bytes" | "other"; - expected: any; - skipCondition?: () => boolean; - } - - const testCases: TestCase[] = [ - { - description: "should stringify body if not FormData in Node environment", - input: { key: "value" }, - type: "json", - expected: '{"key":"value"}', - skipCondition: () => RUNTIME.type !== "node", - }, - { - description: "should stringify body if not FormData in browser environment", - input: { key: "value" }, - type: "json", - expected: '{"key":"value"}', - skipCondition: () => RUNTIME.type !== "browser", - }, - { - description: "should return the Uint8Array", - input: new Uint8Array([1, 2, 3]), - type: "bytes", - expected: new Uint8Array([1, 2, 3]), - }, - { - description: "should serialize objects for form-urlencoded content type", - input: { username: "johndoe", email: "john@example.com" }, - type: "form", - expected: "username=johndoe&email=john%40example.com", - }, - { - description: "should serialize complex nested objects and arrays for form-urlencoded content type", - input: { - user: { - profile: { - name: "John Doe", - settings: { - theme: "dark", - notifications: true, - }, - }, - tags: ["admin", "user"], - contacts: [ - { type: "email", value: "john@example.com" }, - { type: "phone", value: "+1234567890" }, - ], - }, - filters: { - status: ["active", "pending"], - metadata: { - created: "2024-01-01", - categories: ["electronics", "books"], - }, - }, - preferences: ["notifications", "updates"], - }, - type: "form", - expected: - "user%5Bprofile%5D%5Bname%5D=John%20Doe&" + - "user%5Bprofile%5D%5Bsettings%5D%5Btheme%5D=dark&" + - "user%5Bprofile%5D%5Bsettings%5D%5Bnotifications%5D=true&" + - "user%5Btags%5D=admin&" + - "user%5Btags%5D=user&" + - "user%5Bcontacts%5D%5Btype%5D=email&" + - "user%5Bcontacts%5D%5Bvalue%5D=john%40example.com&" + - "user%5Bcontacts%5D%5Btype%5D=phone&" + - "user%5Bcontacts%5D%5Bvalue%5D=%2B1234567890&" + - "filters%5Bstatus%5D=active&" + - "filters%5Bstatus%5D=pending&" + - "filters%5Bmetadata%5D%5Bcreated%5D=2024-01-01&" + - "filters%5Bmetadata%5D%5Bcategories%5D=electronics&" + - "filters%5Bmetadata%5D%5Bcategories%5D=books&" + - "preferences=notifications&" + - "preferences=updates", - }, - { - description: "should return the input for pre-serialized form-urlencoded strings", - input: "key=value&another=param", - type: "other", - expected: "key=value&another=param", - }, - { - description: "should JSON stringify objects", - input: { key: "value" }, - type: "json", - expected: '{"key":"value"}', - }, - ]; - - testCases.forEach(({ description, input, type, expected, skipCondition }) => { - it(description, async () => { - if (skipCondition?.()) { - return; - } - - const result = await getRequestBody({ - body: input, - type, - }); - - if (input instanceof Uint8Array) { - expect(result).toBe(input); - } else { - expect(result).toBe(expected); - } - }); - }); - - it("should return FormData in browser environment", async () => { - if (RUNTIME.type === "browser") { - const formData = new FormData(); - formData.append("key", "value"); - const result = await getRequestBody({ - body: formData, - type: "file", - }); - expect(result).toBe(formData); - } - }); -}); diff --git a/tests/unit/fetcher/getResponseBody.test.ts b/tests/unit/fetcher/getResponseBody.test.ts deleted file mode 100644 index ad6be7fc..00000000 --- a/tests/unit/fetcher/getResponseBody.test.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { getResponseBody } from "../../../src/core/fetcher/getResponseBody"; - -import { RUNTIME } from "../../../src/core/runtime"; - -describe("Test getResponseBody", () => { - interface SimpleTestCase { - description: string; - responseData: string | Record; - responseType?: "blob" | "sse" | "streaming" | "text"; - expected: any; - skipCondition?: () => boolean; - } - - const simpleTestCases: SimpleTestCase[] = [ - { - description: "should handle text response type", - responseData: "test text", - responseType: "text", - expected: "test text", - }, - { - description: "should handle JSON response", - responseData: { key: "value" }, - expected: { key: "value" }, - }, - { - description: "should handle empty response", - responseData: "", - expected: undefined, - }, - { - description: "should handle non-JSON response", - responseData: "invalid json", - expected: { - ok: false, - error: { - reason: "non-json", - statusCode: 200, - rawBody: "invalid json", - }, - }, - }, - ]; - - simpleTestCases.forEach(({ description, responseData, responseType, expected, skipCondition }) => { - it(description, async () => { - if (skipCondition?.()) { - return; - } - - const mockResponse = new Response( - typeof responseData === "string" ? responseData : JSON.stringify(responseData), - ); - const result = await getResponseBody(mockResponse, responseType); - expect(result).toEqual(expected); - }); - }); - - it("should handle blob response type", async () => { - const mockBlob = new Blob(["test"], { type: "text/plain" }); - const mockResponse = new Response(mockBlob); - const result = await getResponseBody(mockResponse, "blob"); - // @ts-expect-error - expect(result.constructor.name).toBe("Blob"); - }); - - it("should handle sse response type", async () => { - if (RUNTIME.type === "node") { - const mockStream = new ReadableStream(); - const mockResponse = new Response(mockStream); - const result = await getResponseBody(mockResponse, "sse"); - expect(result).toBe(mockStream); - } - }); - - it("should handle streaming response type", async () => { - const encoder = new TextEncoder(); - const testData = "test stream data"; - const mockStream = new ReadableStream({ - start(controller) { - controller.enqueue(encoder.encode(testData)); - controller.close(); - }, - }); - - const mockResponse = new Response(mockStream); - const result = (await getResponseBody(mockResponse, "streaming")) as ReadableStream; - - expect(result).toBeInstanceOf(ReadableStream); - - const reader = result.getReader(); - const decoder = new TextDecoder(); - const { value } = await reader.read(); - const streamContent = decoder.decode(value); - expect(streamContent).toBe(testData); - }); -}); diff --git a/tests/unit/fetcher/logging.test.ts b/tests/unit/fetcher/logging.test.ts deleted file mode 100644 index 366c9b6c..00000000 --- a/tests/unit/fetcher/logging.test.ts +++ /dev/null @@ -1,517 +0,0 @@ -import { fetcherImpl } from "../../../src/core/fetcher/Fetcher"; - -function createMockLogger() { - return { - debug: vi.fn(), - info: vi.fn(), - warn: vi.fn(), - error: vi.fn(), - }; -} - -function mockSuccessResponse(data: unknown = { data: "test" }, status = 200, statusText = "OK") { - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify(data), { - status, - statusText, - }), - ); -} - -function mockErrorResponse(data: unknown = { error: "Error" }, status = 404, statusText = "Not Found") { - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify(data), { - status, - statusText, - }), - ); -} - -describe("Fetcher Logging Integration", () => { - describe("Request Logging", () => { - it("should log successful request at debug level", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "POST", - headers: { "Content-Type": "application/json" }, - body: { test: "data" }, - contentType: "application/json", - requestType: "json", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - method: "POST", - url: "https://example.com/api", - headers: expect.toContainHeaders({ - "Content-Type": "application/json", - }), - hasBody: true, - }), - ); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "HTTP request succeeded", - expect.objectContaining({ - method: "POST", - url: "https://example.com/api", - statusCode: 200, - }), - ); - }); - - it("should not log debug messages at info level for successful requests", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "info", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).not.toHaveBeenCalled(); - }); - - it("should log request with body flag", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "POST", - body: { data: "test" }, - contentType: "application/json", - requestType: "json", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - hasBody: true, - }), - ); - }); - - it("should log request without body flag", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - hasBody: false, - }), - ); - }); - - it("should not log when silent mode is enabled", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: true, - }, - }); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).not.toHaveBeenCalled(); - expect(mockLogger.warn).not.toHaveBeenCalled(); - expect(mockLogger.error).not.toHaveBeenCalled(); - }); - - it("should not log when no logging config is provided", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - }); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - }); - }); - - describe("Error Logging", () => { - it("should log 4xx errors at error level", async () => { - const mockLogger = createMockLogger(); - mockErrorResponse({ error: "Not found" }, 404, "Not Found"); - - const result = await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(result.ok).toBe(false); - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request failed with error status", - expect.objectContaining({ - method: "GET", - url: "https://example.com/api", - statusCode: 404, - }), - ); - }); - - it("should log 5xx errors at error level", async () => { - const mockLogger = createMockLogger(); - mockErrorResponse({ error: "Internal error" }, 500, "Internal Server Error"); - - const result = await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(result.ok).toBe(false); - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request failed with error status", - expect.objectContaining({ - method: "GET", - url: "https://example.com/api", - statusCode: 500, - }), - ); - }); - - it("should log aborted request errors", async () => { - const mockLogger = createMockLogger(); - - const abortController = new AbortController(); - abortController.abort(); - - global.fetch = vi.fn().mockRejectedValue(new Error("Aborted")); - - const result = await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - abortSignal: abortController.signal, - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(result.ok).toBe(false); - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request was aborted", - expect.objectContaining({ - method: "GET", - url: "https://example.com/api", - }), - ); - }); - - it("should log timeout errors", async () => { - const mockLogger = createMockLogger(); - - const timeoutError = new Error("Request timeout"); - timeoutError.name = "AbortError"; - - global.fetch = vi.fn().mockRejectedValue(timeoutError); - - const result = await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(result.ok).toBe(false); - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request timed out", - expect.objectContaining({ - method: "GET", - url: "https://example.com/api", - timeoutMs: undefined, - }), - ); - }); - - it("should log unknown errors", async () => { - const mockLogger = createMockLogger(); - - const unknownError = new Error("Unknown error"); - - global.fetch = vi.fn().mockRejectedValue(unknownError); - - const result = await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(result.ok).toBe(false); - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request failed with error", - expect.objectContaining({ - method: "GET", - url: "https://example.com/api", - errorMessage: "Unknown error", - }), - ); - }); - }); - - describe("Logging with Redaction", () => { - it("should redact sensitive data in error logs", async () => { - const mockLogger = createMockLogger(); - mockErrorResponse({ error: "Unauthorized" }, 401, "Unauthorized"); - - await fetcherImpl({ - url: "https://example.com/api?api_key=secret", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request failed with error status", - expect.objectContaining({ - url: "https://example.com/api?api_key=[REDACTED]", - }), - ); - }); - }); - - describe("Different HTTP Methods", () => { - it("should log GET requests", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - method: "GET", - }), - ); - }); - - it("should log POST requests", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse({ data: "test" }, 201, "Created"); - - await fetcherImpl({ - url: "https://example.com/api", - method: "POST", - body: { data: "test" }, - contentType: "application/json", - requestType: "json", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - method: "POST", - }), - ); - }); - - it("should log PUT requests", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "PUT", - body: { data: "test" }, - contentType: "application/json", - requestType: "json", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - method: "PUT", - }), - ); - }); - - it("should log DELETE requests", async () => { - const mockLogger = createMockLogger(); - global.fetch = vi.fn().mockResolvedValue( - new Response(null, { - status: 200, - statusText: "OK", - }), - ); - - await fetcherImpl({ - url: "https://example.com/api", - method: "DELETE", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - method: "DELETE", - }), - ); - }); - }); - - describe("Status Code Logging", () => { - it("should log 2xx success status codes", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse({ data: "test" }, 201, "Created"); - - await fetcherImpl({ - url: "https://example.com/api", - method: "POST", - body: { data: "test" }, - contentType: "application/json", - requestType: "json", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "HTTP request succeeded", - expect.objectContaining({ - statusCode: 201, - }), - ); - }); - - it("should log 3xx redirect status codes as success", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse({ data: "test" }, 301, "Moved Permanently"); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "HTTP request succeeded", - expect.objectContaining({ - statusCode: 301, - }), - ); - }); - }); -}); diff --git a/tests/unit/fetcher/makeRequest.test.ts b/tests/unit/fetcher/makeRequest.test.ts deleted file mode 100644 index ea49466a..00000000 --- a/tests/unit/fetcher/makeRequest.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { Mock } from "vitest"; -import { makeRequest } from "../../../src/core/fetcher/makeRequest"; - -describe("Test makeRequest", () => { - const mockPostUrl = "https://httpbin.org/post"; - const mockGetUrl = "https://httpbin.org/get"; - const mockHeaders = { "Content-Type": "application/json" }; - const mockBody = JSON.stringify({ key: "value" }); - - let mockFetch: Mock; - - beforeEach(() => { - mockFetch = vi.fn(); - mockFetch.mockResolvedValue(new Response(JSON.stringify({ test: "successful" }), { status: 200 })); - }); - - it("should handle POST request correctly", async () => { - const response = await makeRequest(mockFetch, mockPostUrl, "POST", mockHeaders, mockBody); - const responseBody = await response.json(); - expect(responseBody).toEqual({ test: "successful" }); - expect(mockFetch).toHaveBeenCalledTimes(1); - const [calledUrl, calledOptions] = mockFetch.mock.calls[0]; - expect(calledUrl).toBe(mockPostUrl); - expect(calledOptions).toEqual( - expect.objectContaining({ - method: "POST", - headers: mockHeaders, - body: mockBody, - credentials: undefined, - }), - ); - expect(calledOptions.signal).toBeDefined(); - expect(calledOptions.signal).toBeInstanceOf(AbortSignal); - }); - - it("should handle GET request correctly", async () => { - const response = await makeRequest(mockFetch, mockGetUrl, "GET", mockHeaders, undefined); - const responseBody = await response.json(); - expect(responseBody).toEqual({ test: "successful" }); - expect(mockFetch).toHaveBeenCalledTimes(1); - const [calledUrl, calledOptions] = mockFetch.mock.calls[0]; - expect(calledUrl).toBe(mockGetUrl); - expect(calledOptions).toEqual( - expect.objectContaining({ - method: "GET", - headers: mockHeaders, - body: undefined, - credentials: undefined, - }), - ); - expect(calledOptions.signal).toBeDefined(); - expect(calledOptions.signal).toBeInstanceOf(AbortSignal); - }); -}); diff --git a/tests/unit/fetcher/redacting.test.ts b/tests/unit/fetcher/redacting.test.ts deleted file mode 100644 index d599376b..00000000 --- a/tests/unit/fetcher/redacting.test.ts +++ /dev/null @@ -1,1115 +0,0 @@ -import { fetcherImpl } from "../../../src/core/fetcher/Fetcher"; - -function createMockLogger() { - return { - debug: vi.fn(), - info: vi.fn(), - warn: vi.fn(), - error: vi.fn(), - }; -} - -function mockSuccessResponse(data: unknown = { data: "test" }, status = 200, statusText = "OK") { - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify(data), { - status, - statusText, - }), - ); -} - -describe("Redacting Logic", () => { - describe("Header Redaction", () => { - it("should redact authorization header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { Authorization: "Bearer secret-token-12345" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - Authorization: "[REDACTED]", - }), - }), - ); - }); - - it("should redact api-key header (case-insensitive)", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "X-API-KEY": "secret-api-key" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "X-API-KEY": "[REDACTED]", - }), - }), - ); - }); - - it("should redact cookie header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { Cookie: "session=abc123; token=xyz789" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - Cookie: "[REDACTED]", - }), - }), - ); - }); - - it("should redact x-auth-token header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "x-auth-token": "auth-token-12345" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "x-auth-token": "[REDACTED]", - }), - }), - ); - }); - - it("should redact proxy-authorization header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "Proxy-Authorization": "Basic credentials" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "Proxy-Authorization": "[REDACTED]", - }), - }), - ); - }); - - it("should redact x-csrf-token header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "X-CSRF-Token": "csrf-token-abc" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "X-CSRF-Token": "[REDACTED]", - }), - }), - ); - }); - - it("should redact www-authenticate header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "WWW-Authenticate": "Bearer realm=example" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "WWW-Authenticate": "[REDACTED]", - }), - }), - ); - }); - - it("should redact x-session-token header", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { "X-Session-Token": "session-token-xyz" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "X-Session-Token": "[REDACTED]", - }), - }), - ); - }); - - it("should not redact non-sensitive headers", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { - "Content-Type": "application/json", - "User-Agent": "Test/1.0", - Accept: "application/json", - }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - "Content-Type": "application/json", - "User-Agent": "Test/1.0", - Accept: "application/json", - }), - }), - ); - }); - - it("should redact multiple sensitive headers at once", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - headers: { - Authorization: "Bearer token", - "X-API-Key": "api-key", - Cookie: "session=123", - "Content-Type": "application/json", - }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - headers: expect.toContainHeaders({ - Authorization: "[REDACTED]", - "X-API-Key": "[REDACTED]", - Cookie: "[REDACTED]", - "Content-Type": "application/json", - }), - }), - ); - }); - }); - - describe("Response Header Redaction", () => { - it("should redact Set-Cookie in response headers", async () => { - const mockLogger = createMockLogger(); - - const mockHeaders = new Headers(); - mockHeaders.set("Set-Cookie", "session=abc123; HttpOnly; Secure"); - mockHeaders.set("Content-Type", "application/json"); - - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify({ data: "test" }), { - status: 200, - statusText: "OK", - headers: mockHeaders, - }), - ); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "HTTP request succeeded", - expect.objectContaining({ - responseHeaders: expect.toContainHeaders({ - "set-cookie": "[REDACTED]", - "content-type": "application/json", - }), - }), - ); - }); - - it("should redact authorization in response headers", async () => { - const mockLogger = createMockLogger(); - - const mockHeaders = new Headers(); - mockHeaders.set("Authorization", "Bearer token-123"); - mockHeaders.set("Content-Type", "application/json"); - - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify({ data: "test" }), { - status: 200, - statusText: "OK", - headers: mockHeaders, - }), - ); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "HTTP request succeeded", - expect.objectContaining({ - responseHeaders: expect.toContainHeaders({ - authorization: "[REDACTED]", - "content-type": "application/json", - }), - }), - ); - }); - - it("should redact response headers in error responses", async () => { - const mockLogger = createMockLogger(); - - const mockHeaders = new Headers(); - mockHeaders.set("WWW-Authenticate", "Bearer realm=example"); - mockHeaders.set("Content-Type", "application/json"); - - global.fetch = vi.fn().mockResolvedValue( - new Response(JSON.stringify({ error: "Unauthorized" }), { - status: 401, - statusText: "Unauthorized", - headers: mockHeaders, - }), - ); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "error", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.error).toHaveBeenCalledWith( - "HTTP request failed with error status", - expect.objectContaining({ - responseHeaders: expect.toContainHeaders({ - "www-authenticate": "[REDACTED]", - "content-type": "application/json", - }), - }), - ); - }); - }); - - describe("Query Parameter Redaction", () => { - it("should redact api_key query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { api_key: "secret-key" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - api_key: "[REDACTED]", - }), - }), - ); - }); - - it("should redact token query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { token: "secret-token" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - token: "[REDACTED]", - }), - }), - ); - }); - - it("should redact access_token query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { access_token: "secret-access-token" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - access_token: "[REDACTED]", - }), - }), - ); - }); - - it("should redact password query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { password: "secret-password" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - password: "[REDACTED]", - }), - }), - ); - }); - - it("should redact secret query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { secret: "secret-value" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - secret: "[REDACTED]", - }), - }), - ); - }); - - it("should redact session_id query parameter", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { session_id: "session-123" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - session_id: "[REDACTED]", - }), - }), - ); - }); - - it("should not redact non-sensitive query parameters", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { - page: "1", - limit: "10", - sort: "name", - }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - page: "1", - limit: "10", - sort: "name", - }), - }), - ); - }); - - it("should not redact parameters containing 'auth' substring like 'author'", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { - author: "john", - authenticate: "false", - authorization_level: "user", - }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - author: "john", - authenticate: "false", - authorization_level: "user", - }), - }), - ); - }); - - it("should handle undefined query parameters", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: undefined, - }), - ); - }); - - it("should redact case-insensitive query parameters", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - queryParameters: { API_KEY: "secret-key", Token: "secret-token" }, - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - queryParameters: expect.objectContaining({ - API_KEY: "[REDACTED]", - Token: "[REDACTED]", - }), - }), - ); - }); - }); - - describe("URL Redaction", () => { - it("should redact credentials in URL", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://user:password@example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://[REDACTED]@example.com/api", - }), - ); - }); - - it("should redact api_key in query string", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?api_key=secret-key&page=1", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?api_key=[REDACTED]&page=1", - }), - ); - }); - - it("should redact token in query string", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?token=secret-token", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?token=[REDACTED]", - }), - ); - }); - - it("should redact password in query string", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?username=user&password=secret", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?username=user&password=[REDACTED]", - }), - ); - }); - - it("should not redact non-sensitive query strings", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?page=1&limit=10&sort=name", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?page=1&limit=10&sort=name", - }), - ); - }); - - it("should not redact URL parameters containing 'auth' substring like 'author'", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?author=john&authenticate=false&page=1", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?author=john&authenticate=false&page=1", - }), - ); - }); - - it("should handle URL with fragment", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?token=secret#section", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?token=[REDACTED]#section", - }), - ); - }); - - it("should redact URL-encoded query parameters", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?api%5Fkey=secret", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?api%5Fkey=[REDACTED]", - }), - ); - }); - - it("should handle URL without query string", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api", - }), - ); - }); - - it("should handle empty query string", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?", - }), - ); - }); - - it("should redact multiple sensitive parameters in URL", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?api_key=secret1&token=secret2&page=1", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?api_key=[REDACTED]&token=[REDACTED]&page=1", - }), - ); - }); - - it("should redact both credentials and query parameters", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://user:pass@example.com/api?token=secret", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://[REDACTED]@example.com/api?token=[REDACTED]", - }), - ); - }); - - it("should use fast path for URLs without sensitive keywords", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?page=1&limit=10&sort=name&filter=value", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?page=1&limit=10&sort=name&filter=value", - }), - ); - }); - - it("should handle query parameter without value", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?flag&token=secret", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?flag&token=[REDACTED]", - }), - ); - }); - - it("should handle URL with multiple @ symbols in credentials", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://user@example.com:pass@host.com/api", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://[REDACTED]@host.com/api", - }), - ); - }); - - it("should handle URL with @ in query parameter but not in credentials", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://example.com/api?email=user@example.com", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://example.com/api?email=user@example.com", - }), - ); - }); - - it("should handle URL with both credentials and @ in path", async () => { - const mockLogger = createMockLogger(); - mockSuccessResponse(); - - await fetcherImpl({ - url: "https://user:pass@example.com/users/@username", - method: "GET", - responseType: "json", - maxRetries: 0, - logging: { - level: "debug", - logger: mockLogger, - silent: false, - }, - }); - - expect(mockLogger.debug).toHaveBeenCalledWith( - "Making HTTP request", - expect.objectContaining({ - url: "https://[REDACTED]@example.com/users/@username", - }), - ); - }); - }); -}); diff --git a/tests/unit/fetcher/requestWithRetries.test.ts b/tests/unit/fetcher/requestWithRetries.test.ts deleted file mode 100644 index d2266136..00000000 --- a/tests/unit/fetcher/requestWithRetries.test.ts +++ /dev/null @@ -1,230 +0,0 @@ -import type { Mock, MockInstance } from "vitest"; -import { requestWithRetries } from "../../../src/core/fetcher/requestWithRetries"; - -describe("requestWithRetries", () => { - let mockFetch: Mock; - let originalMathRandom: typeof Math.random; - let setTimeoutSpy: MockInstance; - - beforeEach(() => { - mockFetch = vi.fn(); - originalMathRandom = Math.random; - - Math.random = vi.fn(() => 0.5); - - vi.useFakeTimers({ - toFake: [ - "setTimeout", - "clearTimeout", - "setInterval", - "clearInterval", - "setImmediate", - "clearImmediate", - "Date", - "performance", - "requestAnimationFrame", - "cancelAnimationFrame", - "requestIdleCallback", - "cancelIdleCallback", - ], - }); - }); - - afterEach(() => { - Math.random = originalMathRandom; - vi.clearAllMocks(); - vi.clearAllTimers(); - }); - - it("should retry on retryable status codes", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - const retryableStatuses = [408, 429, 500, 502]; - let callCount = 0; - - mockFetch.mockImplementation(async () => { - if (callCount < retryableStatuses.length) { - return new Response("", { status: retryableStatuses[callCount++] }); - } - return new Response("", { status: 200 }); - }); - - const responsePromise = requestWithRetries(() => mockFetch(), retryableStatuses.length); - await vi.runAllTimersAsync(); - const response = await responsePromise; - - expect(mockFetch).toHaveBeenCalledTimes(retryableStatuses.length + 1); - expect(response.status).toBe(200); - }); - - it("should respect maxRetries limit", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - const maxRetries = 2; - mockFetch.mockResolvedValue(new Response("", { status: 500 })); - - const responsePromise = requestWithRetries(() => mockFetch(), maxRetries); - await vi.runAllTimersAsync(); - const response = await responsePromise; - - expect(mockFetch).toHaveBeenCalledTimes(maxRetries + 1); - expect(response.status).toBe(500); - }); - - it("should not retry on success status codes", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - const successStatuses = [200, 201, 202]; - - for (const status of successStatuses) { - mockFetch.mockReset(); - setTimeoutSpy.mockClear(); - mockFetch.mockResolvedValueOnce(new Response("", { status })); - - const responsePromise = requestWithRetries(() => mockFetch(), 3); - await vi.runAllTimersAsync(); - await responsePromise; - - expect(mockFetch).toHaveBeenCalledTimes(1); - expect(setTimeoutSpy).not.toHaveBeenCalled(); - } - }); - - interface RetryHeaderTestCase { - description: string; - headerName: string; - headerValue: string | (() => string); - expectedDelayMin: number; - expectedDelayMax: number; - } - - const retryHeaderTests: RetryHeaderTestCase[] = [ - { - description: "should respect retry-after header with seconds value", - headerName: "retry-after", - headerValue: "5", - expectedDelayMin: 4000, - expectedDelayMax: 6000, - }, - { - description: "should respect retry-after header with HTTP date value", - headerName: "retry-after", - headerValue: () => new Date(Date.now() + 3000).toUTCString(), - expectedDelayMin: 2000, - expectedDelayMax: 4000, - }, - { - description: "should respect x-ratelimit-reset header", - headerName: "x-ratelimit-reset", - headerValue: () => Math.floor((Date.now() + 4000) / 1000).toString(), - expectedDelayMin: 3000, - expectedDelayMax: 6000, - }, - ]; - - retryHeaderTests.forEach(({ description, headerName, headerValue, expectedDelayMin, expectedDelayMax }) => { - it(description, async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - const value = typeof headerValue === "function" ? headerValue() : headerValue; - mockFetch - .mockResolvedValueOnce( - new Response("", { - status: 429, - headers: new Headers({ [headerName]: value }), - }), - ) - .mockResolvedValueOnce(new Response("", { status: 200 })); - - const responsePromise = requestWithRetries(() => mockFetch(), 1); - await vi.runAllTimersAsync(); - const response = await responsePromise; - - expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), expect.any(Number)); - const actualDelay = setTimeoutSpy.mock.calls[0][1]; - expect(actualDelay).toBeGreaterThan(expectedDelayMin); - expect(actualDelay).toBeLessThan(expectedDelayMax); - expect(response.status).toBe(200); - }); - }); - - it("should apply correct exponential backoff with jitter", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - mockFetch.mockResolvedValue(new Response("", { status: 500 })); - const maxRetries = 3; - const expectedDelays = [1000, 2000, 4000]; - - const responsePromise = requestWithRetries(() => mockFetch(), maxRetries); - await vi.runAllTimersAsync(); - await responsePromise; - - expect(setTimeoutSpy).toHaveBeenCalledTimes(expectedDelays.length); - - expectedDelays.forEach((delay, index) => { - expect(setTimeoutSpy).toHaveBeenNthCalledWith(index + 1, expect.any(Function), delay); - }); - - expect(mockFetch).toHaveBeenCalledTimes(maxRetries + 1); - }); - - it("should handle concurrent retries independently", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - mockFetch - .mockResolvedValueOnce(new Response("", { status: 500 })) - .mockResolvedValueOnce(new Response("", { status: 500 })) - .mockResolvedValueOnce(new Response("", { status: 200 })) - .mockResolvedValueOnce(new Response("", { status: 200 })); - - const promise1 = requestWithRetries(() => mockFetch(), 1); - const promise2 = requestWithRetries(() => mockFetch(), 1); - - await vi.runAllTimersAsync(); - const [response1, response2] = await Promise.all([promise1, promise2]); - - expect(response1.status).toBe(200); - expect(response2.status).toBe(200); - }); - - it("should cap delay at MAX_RETRY_DELAY for large header values", async () => { - setTimeoutSpy = vi.spyOn(global, "setTimeout").mockImplementation((callback: (args: void) => void) => { - process.nextTick(callback); - return null as any; - }); - - mockFetch - .mockResolvedValueOnce( - new Response("", { - status: 429, - headers: new Headers({ "retry-after": "120" }), // 120 seconds = 120000ms > MAX_RETRY_DELAY (60000ms) - }), - ) - .mockResolvedValueOnce(new Response("", { status: 200 })); - - const responsePromise = requestWithRetries(() => mockFetch(), 1); - await vi.runAllTimersAsync(); - const response = await responsePromise; - - expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), 60000); - expect(response.status).toBe(200); - }); -}); diff --git a/tests/unit/fetcher/signals.test.ts b/tests/unit/fetcher/signals.test.ts deleted file mode 100644 index d7b6d1e6..00000000 --- a/tests/unit/fetcher/signals.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { anySignal, getTimeoutSignal } from "../../../src/core/fetcher/signals"; - -describe("Test getTimeoutSignal", () => { - beforeEach(() => { - vi.useFakeTimers(); - }); - - afterEach(() => { - vi.useRealTimers(); - }); - - it("should return an object with signal and abortId", () => { - const { signal, abortId } = getTimeoutSignal(1000); - - expect(signal).toBeDefined(); - expect(abortId).toBeDefined(); - expect(signal).toBeInstanceOf(AbortSignal); - expect(signal.aborted).toBe(false); - }); - - it("should create a signal that aborts after the specified timeout", () => { - const timeoutMs = 5000; - const { signal } = getTimeoutSignal(timeoutMs); - - expect(signal.aborted).toBe(false); - - vi.advanceTimersByTime(timeoutMs - 1); - expect(signal.aborted).toBe(false); - - vi.advanceTimersByTime(1); - expect(signal.aborted).toBe(true); - }); -}); - -describe("Test anySignal", () => { - it("should return an AbortSignal", () => { - const signal = anySignal(new AbortController().signal); - expect(signal).toBeInstanceOf(AbortSignal); - }); - - it("should abort when any of the input signals is aborted", () => { - const controller1 = new AbortController(); - const controller2 = new AbortController(); - const signal = anySignal(controller1.signal, controller2.signal); - - expect(signal.aborted).toBe(false); - controller1.abort(); - expect(signal.aborted).toBe(true); - }); - - it("should handle an array of signals", () => { - const controller1 = new AbortController(); - const controller2 = new AbortController(); - const signal = anySignal([controller1.signal, controller2.signal]); - - expect(signal.aborted).toBe(false); - controller2.abort(); - expect(signal.aborted).toBe(true); - }); - - it("should abort immediately if one of the input signals is already aborted", () => { - const controller1 = new AbortController(); - const controller2 = new AbortController(); - controller1.abort(); - - const signal = anySignal(controller1.signal, controller2.signal); - expect(signal.aborted).toBe(true); - }); -}); diff --git a/tests/unit/fetcher/test-file.txt b/tests/unit/fetcher/test-file.txt deleted file mode 100644 index c66d471e..00000000 --- a/tests/unit/fetcher/test-file.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file! diff --git a/tests/unit/logging/logger.test.ts b/tests/unit/logging/logger.test.ts deleted file mode 100644 index 2e0b5fe5..00000000 --- a/tests/unit/logging/logger.test.ts +++ /dev/null @@ -1,454 +0,0 @@ -import { ConsoleLogger, createLogger, Logger, LogLevel } from "../../../src/core/logging/logger"; - -function createMockLogger() { - return { - debug: vi.fn(), - info: vi.fn(), - warn: vi.fn(), - error: vi.fn(), - }; -} - -describe("Logger", () => { - describe("LogLevel", () => { - it("should have correct log levels", () => { - expect(LogLevel.Debug).toBe("debug"); - expect(LogLevel.Info).toBe("info"); - expect(LogLevel.Warn).toBe("warn"); - expect(LogLevel.Error).toBe("error"); - }); - }); - - describe("ConsoleLogger", () => { - let consoleLogger: ConsoleLogger; - let consoleSpy: { - debug: ReturnType; - info: ReturnType; - warn: ReturnType; - error: ReturnType; - }; - - beforeEach(() => { - consoleLogger = new ConsoleLogger(); - consoleSpy = { - debug: vi.spyOn(console, "debug").mockImplementation(() => {}), - info: vi.spyOn(console, "info").mockImplementation(() => {}), - warn: vi.spyOn(console, "warn").mockImplementation(() => {}), - error: vi.spyOn(console, "error").mockImplementation(() => {}), - }; - }); - - afterEach(() => { - consoleSpy.debug.mockRestore(); - consoleSpy.info.mockRestore(); - consoleSpy.warn.mockRestore(); - consoleSpy.error.mockRestore(); - }); - - it("should log debug messages", () => { - consoleLogger.debug("debug message", { data: "test" }); - expect(consoleSpy.debug).toHaveBeenCalledWith("debug message", { data: "test" }); - }); - - it("should log info messages", () => { - consoleLogger.info("info message", { data: "test" }); - expect(consoleSpy.info).toHaveBeenCalledWith("info message", { data: "test" }); - }); - - it("should log warn messages", () => { - consoleLogger.warn("warn message", { data: "test" }); - expect(consoleSpy.warn).toHaveBeenCalledWith("warn message", { data: "test" }); - }); - - it("should log error messages", () => { - consoleLogger.error("error message", { data: "test" }); - expect(consoleSpy.error).toHaveBeenCalledWith("error message", { data: "test" }); - }); - - it("should handle multiple arguments", () => { - consoleLogger.debug("message", "arg1", "arg2", { key: "value" }); - expect(consoleSpy.debug).toHaveBeenCalledWith("message", "arg1", "arg2", { key: "value" }); - }); - }); - - describe("Logger with level filtering", () => { - let mockLogger: { - debug: ReturnType; - info: ReturnType; - warn: ReturnType; - error: ReturnType; - }; - - beforeEach(() => { - mockLogger = createMockLogger(); - }); - - describe("Debug level", () => { - it("should log all levels when set to debug", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - logger.debug("debug"); - logger.info("info"); - logger.warn("warn"); - logger.error("error"); - - expect(mockLogger.debug).toHaveBeenCalledWith("debug"); - expect(mockLogger.info).toHaveBeenCalledWith("info"); - expect(mockLogger.warn).toHaveBeenCalledWith("warn"); - expect(mockLogger.error).toHaveBeenCalledWith("error"); - }); - - it("should report correct level checks", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - expect(logger.isDebug()).toBe(true); - expect(logger.isInfo()).toBe(true); - expect(logger.isWarn()).toBe(true); - expect(logger.isError()).toBe(true); - }); - }); - - describe("Info level", () => { - it("should log info, warn, and error when set to info", () => { - const logger = new Logger({ - level: LogLevel.Info, - logger: mockLogger, - silent: false, - }); - - logger.debug("debug"); - logger.info("info"); - logger.warn("warn"); - logger.error("error"); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).toHaveBeenCalledWith("info"); - expect(mockLogger.warn).toHaveBeenCalledWith("warn"); - expect(mockLogger.error).toHaveBeenCalledWith("error"); - }); - - it("should report correct level checks", () => { - const logger = new Logger({ - level: LogLevel.Info, - logger: mockLogger, - silent: false, - }); - - expect(logger.isDebug()).toBe(false); - expect(logger.isInfo()).toBe(true); - expect(logger.isWarn()).toBe(true); - expect(logger.isError()).toBe(true); - }); - }); - - describe("Warn level", () => { - it("should log warn and error when set to warn", () => { - const logger = new Logger({ - level: LogLevel.Warn, - logger: mockLogger, - silent: false, - }); - - logger.debug("debug"); - logger.info("info"); - logger.warn("warn"); - logger.error("error"); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).not.toHaveBeenCalled(); - expect(mockLogger.warn).toHaveBeenCalledWith("warn"); - expect(mockLogger.error).toHaveBeenCalledWith("error"); - }); - - it("should report correct level checks", () => { - const logger = new Logger({ - level: LogLevel.Warn, - logger: mockLogger, - silent: false, - }); - - expect(logger.isDebug()).toBe(false); - expect(logger.isInfo()).toBe(false); - expect(logger.isWarn()).toBe(true); - expect(logger.isError()).toBe(true); - }); - }); - - describe("Error level", () => { - it("should only log error when set to error", () => { - const logger = new Logger({ - level: LogLevel.Error, - logger: mockLogger, - silent: false, - }); - - logger.debug("debug"); - logger.info("info"); - logger.warn("warn"); - logger.error("error"); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).not.toHaveBeenCalled(); - expect(mockLogger.warn).not.toHaveBeenCalled(); - expect(mockLogger.error).toHaveBeenCalledWith("error"); - }); - - it("should report correct level checks", () => { - const logger = new Logger({ - level: LogLevel.Error, - logger: mockLogger, - silent: false, - }); - - expect(logger.isDebug()).toBe(false); - expect(logger.isInfo()).toBe(false); - expect(logger.isWarn()).toBe(false); - expect(logger.isError()).toBe(true); - }); - }); - - describe("Silent mode", () => { - it("should not log anything when silent is true", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: true, - }); - - logger.debug("debug"); - logger.info("info"); - logger.warn("warn"); - logger.error("error"); - - expect(mockLogger.debug).not.toHaveBeenCalled(); - expect(mockLogger.info).not.toHaveBeenCalled(); - expect(mockLogger.warn).not.toHaveBeenCalled(); - expect(mockLogger.error).not.toHaveBeenCalled(); - }); - - it("should report all level checks as false when silent", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: true, - }); - - expect(logger.isDebug()).toBe(false); - expect(logger.isInfo()).toBe(false); - expect(logger.isWarn()).toBe(false); - expect(logger.isError()).toBe(false); - }); - }); - - describe("shouldLog", () => { - it("should correctly determine if level should be logged", () => { - const logger = new Logger({ - level: LogLevel.Info, - logger: mockLogger, - silent: false, - }); - - expect(logger.shouldLog(LogLevel.Debug)).toBe(false); - expect(logger.shouldLog(LogLevel.Info)).toBe(true); - expect(logger.shouldLog(LogLevel.Warn)).toBe(true); - expect(logger.shouldLog(LogLevel.Error)).toBe(true); - }); - - it("should return false for all levels when silent", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: true, - }); - - expect(logger.shouldLog(LogLevel.Debug)).toBe(false); - expect(logger.shouldLog(LogLevel.Info)).toBe(false); - expect(logger.shouldLog(LogLevel.Warn)).toBe(false); - expect(logger.shouldLog(LogLevel.Error)).toBe(false); - }); - }); - - describe("Multiple arguments", () => { - it("should pass multiple arguments to logger", () => { - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - logger.debug("message", "arg1", { key: "value" }, 123); - expect(mockLogger.debug).toHaveBeenCalledWith("message", "arg1", { key: "value" }, 123); - }); - }); - }); - - describe("createLogger", () => { - it("should return default logger when no config provided", () => { - const logger = createLogger(); - expect(logger).toBeInstanceOf(Logger); - }); - - it("should return same logger instance when Logger is passed", () => { - const customLogger = new Logger({ - level: LogLevel.Debug, - logger: new ConsoleLogger(), - silent: false, - }); - - const result = createLogger(customLogger); - expect(result).toBe(customLogger); - }); - - it("should create logger with custom config", () => { - const mockLogger = createMockLogger(); - - const logger = createLogger({ - level: LogLevel.Warn, - logger: mockLogger, - silent: false, - }); - - expect(logger).toBeInstanceOf(Logger); - logger.warn("test"); - expect(mockLogger.warn).toHaveBeenCalledWith("test"); - }); - - it("should use default values for missing config", () => { - const logger = createLogger({}); - expect(logger).toBeInstanceOf(Logger); - }); - - it("should override default level", () => { - const mockLogger = createMockLogger(); - - const logger = createLogger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - logger.debug("test"); - expect(mockLogger.debug).toHaveBeenCalledWith("test"); - }); - - it("should override default silent mode", () => { - const mockLogger = createMockLogger(); - - const logger = createLogger({ - logger: mockLogger, - silent: false, - }); - - logger.info("test"); - expect(mockLogger.info).toHaveBeenCalledWith("test"); - }); - - it("should use provided logger implementation", () => { - const customLogger = createMockLogger(); - - const logger = createLogger({ - logger: customLogger, - level: LogLevel.Debug, - silent: false, - }); - - logger.debug("test"); - expect(customLogger.debug).toHaveBeenCalledWith("test"); - }); - - it("should default to silent: true", () => { - const mockLogger = createMockLogger(); - - const logger = createLogger({ - logger: mockLogger, - level: LogLevel.Debug, - }); - - logger.debug("test"); - expect(mockLogger.debug).not.toHaveBeenCalled(); - }); - }); - - describe("Default logger", () => { - it("should have silent: true by default", () => { - const logger = createLogger(); - expect(logger.shouldLog(LogLevel.Info)).toBe(false); - }); - - it("should not log when using default logger", () => { - const logger = createLogger(); - - logger.info("test"); - expect(logger.isInfo()).toBe(false); - }); - }); - - describe("Edge cases", () => { - it("should handle empty message", () => { - const mockLogger = createMockLogger(); - - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - logger.debug(""); - expect(mockLogger.debug).toHaveBeenCalledWith(""); - }); - - it("should handle no arguments", () => { - const mockLogger = createMockLogger(); - - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - logger.debug("message"); - expect(mockLogger.debug).toHaveBeenCalledWith("message"); - }); - - it("should handle complex objects", () => { - const mockLogger = createMockLogger(); - - const logger = new Logger({ - level: LogLevel.Debug, - logger: mockLogger, - silent: false, - }); - - const complexObject = { - nested: { key: "value" }, - array: [1, 2, 3], - fn: () => "test", - }; - - logger.debug("message", complexObject); - expect(mockLogger.debug).toHaveBeenCalledWith("message", complexObject); - }); - - it("should handle errors as arguments", () => { - const mockLogger = createMockLogger(); - - const logger = new Logger({ - level: LogLevel.Error, - logger: mockLogger, - silent: false, - }); - - const error = new Error("Test error"); - logger.error("Error occurred", error); - expect(mockLogger.error).toHaveBeenCalledWith("Error occurred", error); - }); - }); -}); diff --git a/tests/unit/url/join.test.ts b/tests/unit/url/join.test.ts deleted file mode 100644 index 123488f0..00000000 --- a/tests/unit/url/join.test.ts +++ /dev/null @@ -1,284 +0,0 @@ -import { join } from "../../../src/core/url/index"; - -describe("join", () => { - interface TestCase { - description: string; - base: string; - segments: string[]; - expected: string; - } - - describe("basic functionality", () => { - const basicTests: TestCase[] = [ - { description: "should return empty string for empty base", base: "", segments: [], expected: "" }, - { - description: "should return empty string for empty base with path", - base: "", - segments: ["path"], - expected: "", - }, - { - description: "should handle single segment", - base: "base", - segments: ["segment"], - expected: "base/segment", - }, - { - description: "should handle single segment with trailing slash on base", - base: "base/", - segments: ["segment"], - expected: "base/segment", - }, - { - description: "should handle single segment with leading slash", - base: "base", - segments: ["/segment"], - expected: "base/segment", - }, - { - description: "should handle single segment with both slashes", - base: "base/", - segments: ["/segment"], - expected: "base/segment", - }, - { - description: "should handle multiple segments", - base: "base", - segments: ["path1", "path2", "path3"], - expected: "base/path1/path2/path3", - }, - { - description: "should handle multiple segments with slashes", - base: "base/", - segments: ["/path1/", "/path2/", "/path3/"], - expected: "base/path1/path2/path3/", - }, - ]; - - basicTests.forEach(({ description, base, segments, expected }) => { - it(description, () => { - expect(join(base, ...segments)).toBe(expected); - }); - }); - }); - - describe("URL handling", () => { - const urlTests: TestCase[] = [ - { - description: "should handle absolute URLs", - base: "https://example.com", - segments: ["api", "v1"], - expected: "https://example.com/api/v1", - }, - { - description: "should handle absolute URLs with slashes", - base: "https://example.com/", - segments: ["/api/", "/v1/"], - expected: "https://example.com/api/v1/", - }, - { - description: "should handle absolute URLs with base path", - base: "https://example.com/base", - segments: ["api", "v1"], - expected: "https://example.com/base/api/v1", - }, - { - description: "should preserve URL query parameters", - base: "https://example.com?query=1", - segments: ["api"], - expected: "https://example.com/api?query=1", - }, - { - description: "should preserve URL fragments", - base: "https://example.com#fragment", - segments: ["api"], - expected: "https://example.com/api#fragment", - }, - { - description: "should preserve URL query and fragments", - base: "https://example.com?query=1#fragment", - segments: ["api"], - expected: "https://example.com/api?query=1#fragment", - }, - { - description: "should handle http protocol", - base: "http://example.com", - segments: ["api"], - expected: "http://example.com/api", - }, - { - description: "should handle ftp protocol", - base: "ftp://example.com", - segments: ["files"], - expected: "ftp://example.com/files", - }, - { - description: "should handle ws protocol", - base: "ws://example.com", - segments: ["socket"], - expected: "ws://example.com/socket", - }, - { - description: "should fallback to path joining for malformed URLs", - base: "not-a-url://", - segments: ["path"], - expected: "not-a-url:///path", - }, - ]; - - urlTests.forEach(({ description, base, segments, expected }) => { - it(description, () => { - expect(join(base, ...segments)).toBe(expected); - }); - }); - }); - - describe("edge cases", () => { - const edgeCaseTests: TestCase[] = [ - { - description: "should handle empty segments", - base: "base", - segments: ["", "path"], - expected: "base/path", - }, - { - description: "should handle null segments", - base: "base", - segments: [null as any, "path"], - expected: "base/path", - }, - { - description: "should handle undefined segments", - base: "base", - segments: [undefined as any, "path"], - expected: "base/path", - }, - { - description: "should handle segments with only single slash", - base: "base", - segments: ["/", "path"], - expected: "base/path", - }, - { - description: "should handle segments with only double slash", - base: "base", - segments: ["//", "path"], - expected: "base/path", - }, - { - description: "should handle base paths with trailing slashes", - base: "base/", - segments: ["path"], - expected: "base/path", - }, - { - description: "should handle complex nested paths", - base: "api/v1/", - segments: ["/users/", "/123/", "/profile"], - expected: "api/v1/users/123/profile", - }, - ]; - - edgeCaseTests.forEach(({ description, base, segments, expected }) => { - it(description, () => { - expect(join(base, ...segments)).toBe(expected); - }); - }); - }); - - describe("real-world scenarios", () => { - const realWorldTests: TestCase[] = [ - { - description: "should handle API endpoint construction", - base: "https://api.example.com/v1", - segments: ["users", "123", "posts"], - expected: "https://api.example.com/v1/users/123/posts", - }, - { - description: "should handle file path construction", - base: "/var/www", - segments: ["html", "assets", "images"], - expected: "/var/www/html/assets/images", - }, - { - description: "should handle relative path construction", - base: "../parent", - segments: ["child", "grandchild"], - expected: "../parent/child/grandchild", - }, - { - description: "should handle Windows-style paths", - base: "C:\\Users", - segments: ["Documents", "file.txt"], - expected: "C:\\Users/Documents/file.txt", - }, - ]; - - realWorldTests.forEach(({ description, base, segments, expected }) => { - it(description, () => { - expect(join(base, ...segments)).toBe(expected); - }); - }); - }); - - describe("performance scenarios", () => { - it("should handle many segments efficiently", () => { - const segments = Array(100).fill("segment"); - const result = join("base", ...segments); - expect(result).toBe(`base/${segments.join("/")}`); - }); - - it("should handle long URLs", () => { - const longPath = "a".repeat(1000); - expect(join("https://example.com", longPath)).toBe(`https://example.com/${longPath}`); - }); - }); - - describe("trailing slash preservation", () => { - const trailingSlashTests: TestCase[] = [ - { - description: - "should preserve trailing slash on final result when base has trailing slash and no segments", - base: "https://api.example.com/", - segments: [], - expected: "https://api.example.com/", - }, - { - description: "should preserve trailing slash on v1 path", - base: "https://api.example.com/v1/", - segments: [], - expected: "https://api.example.com/v1/", - }, - { - description: "should preserve trailing slash when last segment has trailing slash", - base: "https://api.example.com", - segments: ["users/"], - expected: "https://api.example.com/users/", - }, - { - description: "should preserve trailing slash with relative path", - base: "api/v1", - segments: ["users/"], - expected: "api/v1/users/", - }, - { - description: "should preserve trailing slash with multiple segments", - base: "https://api.example.com", - segments: ["v1", "collections/"], - expected: "https://api.example.com/v1/collections/", - }, - { - description: "should preserve trailing slash with base path", - base: "base", - segments: ["path1", "path2/"], - expected: "base/path1/path2/", - }, - ]; - - trailingSlashTests.forEach(({ description, base, segments, expected }) => { - it(description, () => { - expect(join(base, ...segments)).toBe(expected); - }); - }); - }); -}); diff --git a/tests/unit/url/qs.test.ts b/tests/unit/url/qs.test.ts deleted file mode 100644 index 42cdffb9..00000000 --- a/tests/unit/url/qs.test.ts +++ /dev/null @@ -1,278 +0,0 @@ -import { toQueryString } from "../../../src/core/url/index"; - -describe("Test qs toQueryString", () => { - interface BasicTestCase { - description: string; - input: any; - expected: string; - } - - describe("Basic functionality", () => { - const basicTests: BasicTestCase[] = [ - { description: "should return empty string for null", input: null, expected: "" }, - { description: "should return empty string for undefined", input: undefined, expected: "" }, - { description: "should return empty string for string primitive", input: "hello", expected: "" }, - { description: "should return empty string for number primitive", input: 42, expected: "" }, - { description: "should return empty string for true boolean", input: true, expected: "" }, - { description: "should return empty string for false boolean", input: false, expected: "" }, - { description: "should handle empty objects", input: {}, expected: "" }, - { - description: "should handle simple key-value pairs", - input: { name: "John", age: 30 }, - expected: "name=John&age=30", - }, - ]; - - basicTests.forEach(({ description, input, expected }) => { - it(description, () => { - expect(toQueryString(input)).toBe(expected); - }); - }); - }); - - describe("Array handling", () => { - interface ArrayTestCase { - description: string; - input: any; - options?: { arrayFormat?: "repeat" | "indices" }; - expected: string; - } - - const arrayTests: ArrayTestCase[] = [ - { - description: "should handle arrays with indices format (default)", - input: { items: ["a", "b", "c"] }, - expected: "items%5B0%5D=a&items%5B1%5D=b&items%5B2%5D=c", - }, - { - description: "should handle arrays with repeat format", - input: { items: ["a", "b", "c"] }, - options: { arrayFormat: "repeat" }, - expected: "items=a&items=b&items=c", - }, - { - description: "should handle empty arrays", - input: { items: [] }, - expected: "", - }, - { - description: "should handle arrays with mixed types", - input: { mixed: ["string", 42, true, false] }, - expected: "mixed%5B0%5D=string&mixed%5B1%5D=42&mixed%5B2%5D=true&mixed%5B3%5D=false", - }, - { - description: "should handle arrays with objects", - input: { users: [{ name: "John" }, { name: "Jane" }] }, - expected: "users%5B0%5D%5Bname%5D=John&users%5B1%5D%5Bname%5D=Jane", - }, - { - description: "should handle arrays with objects in repeat format", - input: { users: [{ name: "John" }, { name: "Jane" }] }, - options: { arrayFormat: "repeat" }, - expected: "users%5Bname%5D=John&users%5Bname%5D=Jane", - }, - ]; - - arrayTests.forEach(({ description, input, options, expected }) => { - it(description, () => { - expect(toQueryString(input, options)).toBe(expected); - }); - }); - }); - - describe("Nested objects", () => { - const nestedTests: BasicTestCase[] = [ - { - description: "should handle nested objects", - input: { user: { name: "John", age: 30 } }, - expected: "user%5Bname%5D=John&user%5Bage%5D=30", - }, - { - description: "should handle deeply nested objects", - input: { user: { profile: { name: "John", settings: { theme: "dark" } } } }, - expected: "user%5Bprofile%5D%5Bname%5D=John&user%5Bprofile%5D%5Bsettings%5D%5Btheme%5D=dark", - }, - { - description: "should handle empty nested objects", - input: { user: {} }, - expected: "", - }, - ]; - - nestedTests.forEach(({ description, input, expected }) => { - it(description, () => { - expect(toQueryString(input)).toBe(expected); - }); - }); - }); - - describe("Encoding", () => { - interface EncodingTestCase { - description: string; - input: any; - options?: { encode?: boolean }; - expected: string; - } - - const encodingTests: EncodingTestCase[] = [ - { - description: "should encode by default", - input: { name: "John Doe", email: "john@example.com" }, - expected: "name=John%20Doe&email=john%40example.com", - }, - { - description: "should not encode when encode is false", - input: { name: "John Doe", email: "john@example.com" }, - options: { encode: false }, - expected: "name=John Doe&email=john@example.com", - }, - { - description: "should encode special characters in keys", - input: { "user name": "John", "email[primary]": "john@example.com" }, - expected: "user%20name=John&email%5Bprimary%5D=john%40example.com", - }, - { - description: "should not encode special characters in keys when encode is false", - input: { "user name": "John", "email[primary]": "john@example.com" }, - options: { encode: false }, - expected: "user name=John&email[primary]=john@example.com", - }, - ]; - - encodingTests.forEach(({ description, input, options, expected }) => { - it(description, () => { - expect(toQueryString(input, options)).toBe(expected); - }); - }); - }); - - describe("Mixed scenarios", () => { - interface MixedTestCase { - description: string; - input: any; - options?: { arrayFormat?: "repeat" | "indices" }; - expected: string; - } - - const mixedTests: MixedTestCase[] = [ - { - description: "should handle complex nested structures", - input: { - filters: { - status: ["active", "pending"], - category: { - type: "electronics", - subcategories: ["phones", "laptops"], - }, - }, - sort: { field: "name", direction: "asc" }, - }, - expected: - "filters%5Bstatus%5D%5B0%5D=active&filters%5Bstatus%5D%5B1%5D=pending&filters%5Bcategory%5D%5Btype%5D=electronics&filters%5Bcategory%5D%5Bsubcategories%5D%5B0%5D=phones&filters%5Bcategory%5D%5Bsubcategories%5D%5B1%5D=laptops&sort%5Bfield%5D=name&sort%5Bdirection%5D=asc", - }, - { - description: "should handle complex nested structures with repeat format", - input: { - filters: { - status: ["active", "pending"], - category: { - type: "electronics", - subcategories: ["phones", "laptops"], - }, - }, - sort: { field: "name", direction: "asc" }, - }, - options: { arrayFormat: "repeat" }, - expected: - "filters%5Bstatus%5D=active&filters%5Bstatus%5D=pending&filters%5Bcategory%5D%5Btype%5D=electronics&filters%5Bcategory%5D%5Bsubcategories%5D=phones&filters%5Bcategory%5D%5Bsubcategories%5D=laptops&sort%5Bfield%5D=name&sort%5Bdirection%5D=asc", - }, - { - description: "should handle arrays with null/undefined values", - input: { items: ["a", null, "c", undefined, "e"] }, - expected: "items%5B0%5D=a&items%5B1%5D=&items%5B2%5D=c&items%5B4%5D=e", - }, - { - description: "should handle objects with null/undefined values", - input: { name: "John", age: null, email: undefined, active: true }, - expected: "name=John&age=&active=true", - }, - ]; - - mixedTests.forEach(({ description, input, options, expected }) => { - it(description, () => { - expect(toQueryString(input, options)).toBe(expected); - }); - }); - }); - - describe("Edge cases", () => { - const edgeCaseTests: BasicTestCase[] = [ - { - description: "should handle numeric keys", - input: { "0": "zero", "1": "one" }, - expected: "0=zero&1=one", - }, - { - description: "should handle boolean values in objects", - input: { enabled: true, disabled: false }, - expected: "enabled=true&disabled=false", - }, - { - description: "should handle empty strings", - input: { name: "", description: "test" }, - expected: "name=&description=test", - }, - { - description: "should handle zero values", - input: { count: 0, price: 0.0 }, - expected: "count=0&price=0", - }, - { - description: "should handle arrays with empty strings", - input: { items: ["a", "", "c"] }, - expected: "items%5B0%5D=a&items%5B1%5D=&items%5B2%5D=c", - }, - ]; - - edgeCaseTests.forEach(({ description, input, expected }) => { - it(description, () => { - expect(toQueryString(input)).toBe(expected); - }); - }); - }); - - describe("Options combinations", () => { - interface OptionsTestCase { - description: string; - input: any; - options?: { arrayFormat?: "repeat" | "indices"; encode?: boolean }; - expected: string; - } - - const optionsTests: OptionsTestCase[] = [ - { - description: "should respect both arrayFormat and encode options", - input: { items: ["a & b", "c & d"] }, - options: { arrayFormat: "repeat", encode: false }, - expected: "items=a & b&items=c & d", - }, - { - description: "should use default options when none provided", - input: { items: ["a", "b"] }, - expected: "items%5B0%5D=a&items%5B1%5D=b", - }, - { - description: "should merge provided options with defaults", - input: { items: ["a", "b"], name: "John Doe" }, - options: { encode: false }, - expected: "items[0]=a&items[1]=b&name=John Doe", - }, - ]; - - optionsTests.forEach(({ description, input, options, expected }) => { - it(description, () => { - expect(toQueryString(input, options)).toBe(expected); - }); - }); - }); -}); diff --git a/tests/unit/utils/setObjectProperty.test.ts b/tests/unit/utils/setObjectProperty.test.ts deleted file mode 100644 index 29f8e638..00000000 --- a/tests/unit/utils/setObjectProperty.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { setObjectProperty } from "../../../src/core/utils/setObjectProperty"; - -interface TestCase { - description: string; - giveObject: object; - givePath: string; - giveValue: any; - wantObject: object; -} - -describe("Test setObjectProperty", () => { - const testCases: TestCase[] = [ - { - description: "empty", - giveObject: {}, - givePath: "", - giveValue: 0, - wantObject: { "": 0 }, - }, - { - description: "top-level primitive", - giveObject: {}, - givePath: "age", - giveValue: 42, - wantObject: { age: 42 }, - }, - { - description: "top-level object", - giveObject: {}, - givePath: "name", - giveValue: { first: "John", last: "Doe" }, - wantObject: { name: { first: "John", last: "Doe" } }, - }, - { - description: "top-level array", - giveObject: {}, - givePath: "values", - giveValue: [1, 2, 3], - wantObject: { values: [1, 2, 3] }, - }, - { - description: "nested object property", - giveObject: { - name: { - first: "John", - }, - }, - givePath: "name.last", - giveValue: "Doe", - wantObject: { name: { first: "John", last: "Doe" } }, - }, - { - description: "deeply nested object property", - giveObject: { - info: { - address: { - street: "123 Main St.", - }, - age: 42, - name: { - last: "Doe", - }, - }, - }, - givePath: "info.name.first", - giveValue: "John", - wantObject: { - info: { age: 42, address: { street: "123 Main St." }, name: { first: "John", last: "Doe" } }, - }, - }, - ]; - test.each(testCases)("$description", ({ giveObject, givePath, giveValue, wantObject }) => { - const result = setObjectProperty(giveObject, givePath, giveValue); - expect(result).toEqual(wantObject); - }); -}); diff --git a/tests/uploads.test.ts b/tests/uploads.test.ts new file mode 100644 index 00000000..ef9c7cec --- /dev/null +++ b/tests/uploads.test.ts @@ -0,0 +1,57 @@ +import fs from 'fs'; +import { toFile, type ResponseLike } from 'intercom-client/uploads'; +import { File } from 'intercom-client/_shims/index'; + +class MyClass { + name: string = 'foo'; +} + +function mockResponse({ url, content }: { url: string; content?: Blob }): ResponseLike { + return { + url, + blob: async () => content as any, + }; +} + +describe('toFile', () => { + it('throws a helpful error for mismatched types', async () => { + await expect( + // @ts-expect-error intentionally mismatched type + toFile({ foo: 'string' }), + ).rejects.toThrowErrorMatchingInlineSnapshot( + `"Unexpected data type: object; constructor: Object; props: ["foo"]"`, + ); + + await expect( + // @ts-expect-error intentionally mismatched type + toFile(new MyClass()), + ).rejects.toThrowErrorMatchingInlineSnapshot( + `"Unexpected data type: object; constructor: MyClass; props: ["name"]"`, + ); + }); + + it('disallows string at the type-level', async () => { + // @ts-expect-error we intentionally do not type support for `string` + // to help people avoid passing a file path + const file = await toFile('contents'); + expect(file.text()).resolves.toEqual('contents'); + }); + + it('extracts a file name from a Response', async () => { + const response = mockResponse({ url: 'https://example.com/my/audio.mp3' }); + const file = await toFile(response); + expect(file.name).toEqual('audio.mp3'); + }); + + it('extracts a file name from a File', async () => { + const input = new File(['foo'], 'input.jsonl'); + const file = await toFile(input); + expect(file.name).toEqual('input.jsonl'); + }); + + it('extracts a file name from a ReadStream', async () => { + const input = fs.createReadStream('tests/uploads.test.ts'); + const file = await toFile(input); + expect(file.name).toEqual('uploads.test.ts'); + }); +}); diff --git a/tests/wire/.gitkeep b/tests/wire/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/wire/admins.test.ts b/tests/wire/admins.test.ts deleted file mode 100644 index 0f4be795..00000000 --- a/tests/wire/admins.test.ts +++ /dev/null @@ -1,686 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("AdminsClient", () => { - test("identify", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }; - server.mockEndpoint().get("/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.admins.identify(); - expect(response).toEqual({ - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }); - }); - - test("away (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true, away_status_reason_id: 12345 }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("away (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("away (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("away (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("away (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("away (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.admins.away({ - admin_id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAllActivityLogs (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - team_assignment_limit: 50, - enabled: true, - consent_id: 149673, - expired_at: "2025-12-04T09:31:57Z", - before: { key: "value" }, - after: { key: "value" }, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - team_assignment_limit: 50, - enabled: true, - consent_id: 149673, - expired_at: "2025-12-04T09:31:57Z", - before: { key: "value" }, - after: { key: "value" }, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.admins.listAllActivityLogs({ - created_at_after: "1677253093", - created_at_before: "1677861493", - }); - expect(response).toEqual({ - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - team_assignment_limit: 50, - enabled: true, - consent_id: 149673, - expired_at: "2025-12-04T09:31:57Z", - before: { - key: "value", - }, - after: { - key: "value", - }, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - team_assignment_limit: 50, - enabled: true, - consent_id: 149673, - expired_at: "2025-12-04T09:31:57Z", - before: { - key: "value", - }, - after: { - key: "value", - }, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }); - }); - - test("listAllActivityLogs (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.admins.listAllActivityLogs({ - created_at_after: "created_at_after", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - ], - }; - server.mockEndpoint().get("/admins").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.admins.list(); - expect(response).toEqual({ - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.admins.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.admins.find({ - admin_id: 1, - }); - expect(response).toEqual({ - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.admins.find({ - admin_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.admins.find({ - admin_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/aiContent.test.ts b/tests/wire/aiContent.test.ts deleted file mode 100644 index fad0e33d..00000000 --- a/tests/wire/aiContent.test.ts +++ /dev/null @@ -1,878 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("AiContentClient", () => { - test("listContentImportSources (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - total_count: 3, - data: [ - { - type: "content_import_source", - id: 33, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/1", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 34, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/2", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 35, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/3", - created_at: 1734537259, - updated_at: 1734537259, - }, - ], - }; - server - .mockEndpoint() - .get("/ai/content_import_sources") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.listContentImportSources(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - total_count: 3, - data: [ - { - type: "content_import_source", - id: 33, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/1", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 34, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/2", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 35, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/3", - created_at: 1734537259, - updated_at: 1734537259, - }, - ], - }); - }); - - test("listContentImportSources (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/content_import_sources") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.listContentImportSources(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("createContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "https://www.example.com" }; - const rawResponseBody = { - type: "content_import_source", - id: 36, - last_synced_at: 1734537261, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537261, - updated_at: 1734537261, - }; - server - .mockEndpoint() - .post("/ai/content_import_sources") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.createContentImportSource({ - url: "https://www.example.com", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 36, - last_synced_at: 1734537261, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537261, - updated_at: 1734537261, - }); - }); - - test("createContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "url" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ai/content_import_sources") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.createContentImportSource({ - url: "url", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("getContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "content_import_source", - id: 38, - last_synced_at: 1734537265, - sync_behavior: "api", - status: "active", - url: "https://support.example.com/us/5", - created_at: 1734537265, - updated_at: 1734537265, - }; - server - .mockEndpoint() - .get("/ai/content_import_sources/source_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.getContentImportSource({ - source_id: "source_id", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 38, - last_synced_at: 1734537265, - sync_behavior: "api", - status: "active", - url: "https://support.example.com/us/5", - created_at: 1734537265, - updated_at: 1734537265, - }); - }); - - test("getContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/content_import_sources/source_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.getContentImportSource({ - source_id: "source_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("updateContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "https://www.example.com" }; - const rawResponseBody = { - type: "content_import_source", - id: 39, - last_synced_at: 1734537267, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537267, - updated_at: 1734537267, - }; - server - .mockEndpoint() - .put("/ai/content_import_sources/source_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.updateContentImportSource({ - source_id: "source_id", - sync_behavior: "api", - url: "https://www.example.com", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 39, - last_synced_at: 1734537267, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537267, - updated_at: 1734537267, - }); - }); - - test("updateContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "url" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ai/content_import_sources/source_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.updateContentImportSource({ - source_id: "source_id", - sync_behavior: "api", - url: "url", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().delete("/ai/content_import_sources/source_id").respondWith().statusCode(200).build(); - - const response = await client.aiContent.deleteContentImportSource({ - source_id: "source_id", - }); - expect(response).toEqual(undefined); - }); - - test("deleteContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/ai/content_import_sources/source_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.deleteContentImportSource({ - source_id: "source_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listExternalPages (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - total_count: 3, - data: [ - { - type: "external_page", - id: "19", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/3", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 42, - external_id: "3", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "18", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/2", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 41, - external_id: "2", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "17", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/1", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 40, - external_id: "1", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - ], - }; - server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.aiContent.listExternalPages(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - total_count: 3, - data: [ - { - type: "external_page", - id: "19", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/3", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 42, - external_id: "3", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "18", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/2", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 41, - external_id: "2", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "17", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/1", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 40, - external_id: "1", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - ], - }); - }); - - test("listExternalPages (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.aiContent.listExternalPages(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("createExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Test", - html: "

Test

", - url: "https://www.example.com", - locale: "en", - source_id: 44, - external_id: "abc1234", - }; - const rawResponseBody = { - type: "external_page", - id: "21", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 44, - external_id: "abc1234", - created_at: 1734537273, - updated_at: 1734537274, - last_ingested_at: 1734537274, - }; - server - .mockEndpoint() - .post("/ai/external_pages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.createExternalPage({ - title: "Test", - html: "

Test

", - url: "https://www.example.com", - source_id: 44, - external_id: "abc1234", - }); - expect(response).toEqual({ - type: "external_page", - id: "21", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 44, - external_id: "abc1234", - created_at: 1734537273, - updated_at: 1734537274, - last_ingested_at: 1734537274, - }); - }); - - test("createExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", html: "html", locale: "en", source_id: 1, external_id: "external_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ai/external_pages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.createExternalPage({ - title: "title", - html: "html", - source_id: 1, - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("getExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "external_page", - id: "23", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/6", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 46, - external_id: "5", - created_at: 1734537278, - updated_at: 1734537278, - last_ingested_at: 1734537278, - }; - server - .mockEndpoint() - .get("/ai/external_pages/page_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.getExternalPage({ - page_id: "page_id", - }); - expect(response).toEqual({ - type: "external_page", - id: "23", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/6", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 46, - external_id: "5", - created_at: 1734537278, - updated_at: 1734537278, - last_ingested_at: 1734537278, - }); - }); - - test("getExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/external_pages/page_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.getExternalPage({ - page_id: "page_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("updateExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Test", - html: "

Test

", - url: "https://www.example.com", - locale: "en", - source_id: 47, - external_id: "5678", - }; - const rawResponseBody = { - type: "external_page", - id: "24", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 47, - external_id: "5678", - created_at: 1734537280, - updated_at: 1734537281, - last_ingested_at: 1734537281, - }; - server - .mockEndpoint() - .put("/ai/external_pages/page_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.updateExternalPage({ - page_id: "page_id", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - source_id: 47, - external_id: "5678", - }); - expect(response).toEqual({ - type: "external_page", - id: "24", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 47, - external_id: "5678", - created_at: 1734537280, - updated_at: 1734537281, - last_ingested_at: 1734537281, - }); - }); - - test("updateExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", html: "html", url: "url", locale: "en", source_id: 1 }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ai/external_pages/page_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.updateExternalPage({ - page_id: "page_id", - title: "title", - html: "html", - url: "url", - source_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "external_page", - id: "22", - title: "My External Content", - html: "", - url: "https://support.example.com/us/5", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 45, - external_id: "4", - created_at: 1734537276, - updated_at: 1734537276, - last_ingested_at: 1734537276, - }; - server - .mockEndpoint() - .delete("/ai/external_pages/page_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.aiContent.deleteExternalPage({ - page_id: "page_id", - }); - expect(response).toEqual({ - type: "external_page", - id: "22", - title: "My External Content", - html: "", - url: "https://support.example.com/us/5", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 45, - external_id: "4", - created_at: 1734537276, - updated_at: 1734537276, - last_ingested_at: 1734537276, - }); - }); - - test("deleteExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/ai/external_pages/page_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.aiContent.deleteExternalPage({ - page_id: "page_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/articles.test.ts b/tests/wire/articles.test.ts deleted file mode 100644 index 35387d31..00000000 --- a/tests/wire/articles.test.ts +++ /dev/null @@ -1,6584 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("ArticlesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { key: "value" }, - total_count: 1, - data: [ - { - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }, - { - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }, - ], - }; - server - .mockEndpoint({ once: false }) - .get("/articles") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - pages: { - key: "value", - }, - total_count: 1, - data: [ - { - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }, - { - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }, - ], - }; - const page = await client.articles.list(); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/articles") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.articles.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - description: "Description of the Article", - body: "Body of the Article", - author_id: 991267497, - state: "published", - parent_id: 145, - parent_type: "collection", - translated_content: { - fr: { - title: "Merci pour tout", - description: "Description de l'article", - body: "Corps de l'article", - author_id: 991267497, - state: "published", - }, - }, - }; - const rawResponseBody = { - type: "article", - id: "42", - workspace_id: "this_is_an_id68_that_should_be_at_least_4", - title: "Thanks for everything", - description: "Description of the Article", - body: '

Body of the Article

', - author_id: 991267497, - state: "published", - created_at: 1734537288, - updated_at: 1734537288, - url: "http://help-center.test/myapp-68/en/articles/42-thanks-for-everything", - parent_id: 145, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.articles.create({ - title: "Thanks for everything", - description: "Description of the Article", - body: "Body of the Article", - author_id: 991267497, - state: "published", - parent_id: 145, - parent_type: "collection", - translated_content: { - fr: { - title: "Merci pour tout", - description: "Description de l'article", - body: "Corps de l'article", - author_id: 991267497, - state: "published", - }, - }, - }); - expect(response).toEqual({ - type: "article", - id: "42", - workspace_id: "this_is_an_id68_that_should_be_at_least_4", - title: "Thanks for everything", - description: "Description of the Article", - body: '

Body of the Article

', - author_id: 991267497, - state: "published", - created_at: 1734537288, - updated_at: 1734537288, - url: "http://help-center.test/myapp-68/en/articles/42-thanks-for-everything", - parent_id: 145, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - description: "Description of the Article", - body: "Body of the Article", - author_id: 1295, - state: "published", - }; - const rawResponseBody = { - type: "article", - id: "42", - workspace_id: "this_is_an_id68_that_should_be_at_least_4", - title: "Thanks for everything", - description: "Description of the Article", - body: '

Body of the Article

', - author_id: 991267497, - state: "published", - created_at: 1734537288, - updated_at: 1734537288, - url: "http://help-center.test/myapp-68/en/articles/42-thanks-for-everything", - parent_id: 145, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.articles.create({ - title: "Thanks for everything", - description: "Description of the Article", - body: "Body of the Article", - author_id: 1295, - state: "published", - }); - expect(response).toEqual({ - type: "article", - id: "42", - workspace_id: "this_is_an_id68_that_should_be_at_least_4", - title: "Thanks for everything", - description: "Description of the Article", - body: '

Body of the Article

', - author_id: 991267497, - state: "published", - created_at: 1734537288, - updated_at: 1734537288, - url: "http://help-center.test/myapp-68/en/articles/42-thanks-for-everything", - parent_id: 145, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/articles").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.create(undefined); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.create(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.articles.find({ - article_id: 1, - }); - expect(response).toEqual({ - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.find({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.find({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "article", - id: "48", - workspace_id: "this_is_an_id80_that_should_be_at_least_4", - title: "Christmas is here!", - description: "", - body: '

New gifts in store for the jolly season

', - author_id: 991267508, - state: "published", - created_at: 1734537297, - updated_at: 1734537298, - url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", - parent_id: 151, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server - .mockEndpoint() - .put("/articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.articles.update({ - article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "article", - id: "48", - workspace_id: "this_is_an_id80_that_should_be_at_least_4", - title: "Christmas is here!", - description: "", - body: '

New gifts in store for the jolly season

', - author_id: 991267508, - state: "published", - created_at: 1734537297, - updated_at: 1734537298, - url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", - parent_id: 151, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "article", - id: "48", - workspace_id: "this_is_an_id80_that_should_be_at_least_4", - title: "Christmas is here!", - description: "", - body: '

New gifts in store for the jolly season

', - author_id: 991267508, - state: "published", - created_at: 1734537297, - updated_at: 1734537298, - url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", - parent_id: 151, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server - .mockEndpoint() - .put("/articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.articles.update({ - article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "article", - id: "48", - workspace_id: "this_is_an_id80_that_should_be_at_least_4", - title: "Christmas is here!", - description: "", - body: '

New gifts in store for the jolly season

', - author_id: 991267508, - state: "published", - created_at: 1734537297, - updated_at: 1734537298, - url: "http://help-center.test/myapp-80/en/articles/48-christmas-is-here", - parent_id: 151, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.articles.update({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.articles.update({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "51", object: "article", deleted: true }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.articles.delete({ - article_id: 1, - }); - expect(response).toEqual({ - id: "51", - object: "article", - deleted: true, - }); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.delete({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.delete({ - article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("search (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [{ article_id: "123" }], - }, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.articles.search({ - phrase: "Getting started", - state: "published", - help_center_id: 1, - highlight: true, - }); - expect(response).toEqual({ - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [ - { - article_id: "123", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - }); - }); - - test("search (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.articles.search(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/awayStatusReasons.test.ts b/tests/wire/awayStatusReasons.test.ts deleted file mode 100644 index f89aa99c..00000000 --- a/tests/wire/awayStatusReasons.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("AwayStatusReasonsClient", () => { - test("listAwayStatusReasons (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = [ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "☕", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]; - server - .mockEndpoint() - .get("/away_status_reasons") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.awayStatusReasons.listAwayStatusReasons(); - expect(response).toEqual([ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "\u2615", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]); - }); - - test("listAwayStatusReasons (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/away_status_reasons") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.awayStatusReasons.listAwayStatusReasons(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/calls.test.ts b/tests/wire/calls.test.ts deleted file mode 100644 index 5fc5aaec..00000000 --- a/tests/wire/calls.test.ts +++ /dev/null @@ -1,410 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("CallsClient", () => { - test("listCalls (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 0, - }, - }; - server.mockEndpoint().get("/calls").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.calls.listCalls({ - page: 1, - per_page: 1, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 0, - }, - }); - }); - - test("listCalls (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/calls").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.calls.listCalls(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("showCall (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: 1734537437, - answered_at: 1734537440, - ended_at: 1734537530, - created_at: 1734537437, - updated_at: 1734537531, - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "answered", - phone: "+15551234567", - fin_recording_url: "https://api.intercom.io/calls/124/recording", - fin_transcription_url: "https://api.intercom.io/calls/124/transcript", - }; - server.mockEndpoint().get("/calls/call_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.calls.showCall({ - call_id: "call_id", - }); - expect(response).toEqual({ - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: 1734537437, - answered_at: 1734537440, - ended_at: 1734537530, - created_at: 1734537437, - updated_at: 1734537531, - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "answered", - phone: "+15551234567", - fin_recording_url: "https://api.intercom.io/calls/124/recording", - fin_transcription_url: "https://api.intercom.io/calls/124/transcript", - }); - }); - - test("showCall (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/calls/call_id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.calls.showCall({ - call_id: "call_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("showCall (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/calls/call_id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.calls.showCall({ - call_id: "call_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("showCallRecording (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().get("/calls/call_id/recording").respondWith().statusCode(200).build(); - - const response = await client.calls.showCallRecording({ - call_id: "call_id", - }); - expect(response).toEqual(undefined); - }); - - test("showCallRecording (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/calls/call_id/recording") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.calls.showCallRecording({ - call_id: "call_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("showCallRecording (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/calls/call_id/recording") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.calls.showCallRecording({ - call_id: "call_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listCallsWithTranscripts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["64619700005694", "64619700005695"] }; - const rawResponseBody = { - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "64619700005694", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - transcript: [{ key: "value" }], - transcript_status: "completed", - }, - ], - }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.calls.listCallsWithTranscripts({ - conversation_ids: ["64619700005694", "64619700005695"], - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "64619700005694", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - transcript: [ - { - key: "value", - }, - ], - transcript_status: "completed", - }, - ], - }); - }); - - test("listCallsWithTranscripts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["conversation_ids", "conversation_ids"] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.calls.listCallsWithTranscripts({ - conversation_ids: ["conversation_ids", "conversation_ids"], - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("listCallsWithTranscripts (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["conversation_ids", "conversation_ids"] }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.calls.listCallsWithTranscripts({ - conversation_ids: ["conversation_ids", "conversation_ids"], - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/companies.test.ts b/tests/wire/companies.test.ts deleted file mode 100644 index 90524081..00000000 --- a/tests/wire/companies.test.ts +++ /dev/null @@ -1,1987 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("CompaniesClient", () => { - test("retrieve (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "offset_pages", page: 1, next: "next", per_page: 2, total_pages: 13 }, - total_count: 100, - data: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, - }, - ], - }; - server.mockEndpoint().get("/companies").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.companies.retrieve({ - name: "my company", - company_id: "12345", - tag_id: "678910", - segment_id: "98765", - page: 1, - per_page: 1, - }); - expect(response).toEqual({ - type: "list", - pages: { - type: "offset_pages", - page: 1, - next: "next", - per_page: 2, - total_pages: 13, - }, - total_count: 100, - data: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: true, - monthly_spend: 155.5, - team_mates: 9, - }, - }, - ], - }); - }); - - test("retrieve (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/companies").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.companies.retrieve(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("retrieve (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/companies").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.companies.retrieve(); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("createOrUpdate (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "my company", company_id: "company_remote_id", remote_created_at: 1374138000 }; - const rawResponseBody = { - type: "company", - id: "6762f0761bb69f9f2193bae2", - name: "my company", - app_id: "this_is_an_id147_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "company_remote_id", - remote_created_at: 1374138000, - created_at: 1734537334, - updated_at: 1734537334, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { creation_source: "api" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .post("/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.createOrUpdate({ - name: "my company", - company_id: "company_remote_id", - remote_created_at: 1374138000, - }); - expect(response).toEqual({ - type: "company", - id: "6762f0761bb69f9f2193bae2", - name: "my company", - app_id: "this_is_an_id147_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "company_remote_id", - remote_created_at: 1374138000, - created_at: 1734537334, - updated_at: 1734537334, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { - creation_source: "api", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("createOrUpdate (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f0761bb69f9f2193bae2", - name: "my company", - app_id: "this_is_an_id147_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "company_remote_id", - remote_created_at: 1374138000, - created_at: 1734537334, - updated_at: 1734537334, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { creation_source: "api" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server.mockEndpoint().post("/companies").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.companies.createOrUpdate(); - expect(response).toEqual({ - type: "company", - id: "6762f0761bb69f9f2193bae2", - name: "my company", - app_id: "this_is_an_id147_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "company_remote_id", - remote_created_at: 1374138000, - created_at: 1734537334, - updated_at: 1734537334, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { - creation_source: "api", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("createOrUpdate (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/companies").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.companies.createOrUpdate(undefined); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("createOrUpdate (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/companies").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.companies.createOrUpdate(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f07f1bb69f9f2193baf5", - name: "company1", - app_id: "this_is_an_id159_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537343, - created_at: 1734537343, - updated_at: 1734537343, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.find({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "company", - id: "6762f07f1bb69f9f2193baf5", - name: "company1", - app_id: "this_is_an_id159_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537343, - created_at: 1734537343, - updated_at: 1734537343, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/companies/company_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.find({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/company_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.find({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "my company", website: "http://www.mycompany.com/" }; - const rawResponseBody = { - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .put("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.update({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - body: { - name: "my company", - website: "http://www.mycompany.com/", - }, - }); - expect(response).toEqual({ - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .put("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.update({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - body: {}, - }); - expect(response).toEqual({ - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/companies/company_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.update({ - company_id: "company_id", - body: undefined, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/companies/company_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.update({ - company_id: "company_id", - body: undefined, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "6762f0881bb69f9f2193bb09", object: "company", deleted: true }; - server - .mockEndpoint() - .delete("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.delete({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - id: "6762f0881bb69f9f2193bb09", - object: "company", - deleted: true, - }); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/companies/company_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.delete({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/companies/company_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.delete({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAttachedContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 50, - total_pages: 0, - }, - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/contacts") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.listAttachedContacts({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 50, - total_pages: 0, - }, - }); - }); - - test("listAttachedContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/companies/company_id/contacts") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.listAttachedContacts({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedContacts (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/company_id/contacts") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.listAttachedContacts({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAttachedSegments (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "segment", - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - person_type: "contact", - count: 3, - }, - ], - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/segments") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.listAttachedSegments({ - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "segment", - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - person_type: "contact", - count: 3, - }, - ], - }); - }); - - test("listAttachedSegments (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/companies/company_id/segments") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.listAttachedSegments({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedSegments (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/company_id/segments") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.listAttachedSegments({ - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "offset_pages", page: 1, next: "next", per_page: 15, total_pages: 1 }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f0941bb69f9f2193bb25", - name: "IntercomQATest1", - app_id: "this_is_an_id189_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537364, - created_at: 1734537364, - updated_at: 1734537364, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }, - ], - }; - server - .mockEndpoint({ once: false }) - .post("/companies/list") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - pages: { - type: "offset_pages", - page: 1, - next: "next", - per_page: 15, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f0941bb69f9f2193bb25", - name: "IntercomQATest1", - app_id: "this_is_an_id189_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537364, - created_at: 1734537364, - updated_at: 1734537364, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }, - ], - }; - const page = await client.companies.list({ - page: 1, - per_page: 1, - order: "desc", - }); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .post("/companies/list") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("scroll (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "company", - id: "6762f0971bb69f9f2193bb2b", - name: "IntercomQATest1", - app_id: "this_is_an_id193_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537367, - created_at: 1734537367, - updated_at: 1734537367, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }, - ], - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 2, - total_pages: 13, - }, - total_count: 100, - scroll_param: "69352cd2-ab5b-42ac-b004-a13d4e55e9b0", - }; - server - .mockEndpoint({ once: false }) - .get("/companies/scroll") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - data: [ - { - type: "company", - id: "6762f0971bb69f9f2193bb2b", - name: "IntercomQATest1", - app_id: "this_is_an_id193_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537367, - created_at: 1734537367, - updated_at: 1734537367, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }, - ], - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 2, - total_pages: 13, - }, - total_count: 100, - scroll_param: "69352cd2-ab5b-42ac-b004-a13d4e55e9b0", - }; - const page = await client.companies.scroll({ - scroll_param: "scroll_param", - }); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("scroll (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/companies/scroll") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.scroll(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("attachContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "6762f09a1bb69f9f2193bb34" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.attachContact({ - contact_id: "contact_id", - id: "6762f09a1bb69f9f2193bb34", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("attachContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "58a430d35458202d41b1e65b" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.attachContact({ - contact_id: "contact_id", - id: "58a430d35458202d41b1e65b", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("attachContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "123" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.attachContact({ - contact_id: "contact_id", - id: "123", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("attachContact (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.attachContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("attachContact (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.attachContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("attachContact (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.attachContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("detachContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f0a01bb69f9f2193bb44", - name: "company8", - app_id: "this_is_an_id205_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537376, - created_at: 1734537376, - updated_at: 1734537377, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }; - server - .mockEndpoint() - .delete("/contacts/58a430d35458202d41b1e65b/companies/58a430d35458202d41b1e65b") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.companies.detachContact({ - contact_id: "58a430d35458202d41b1e65b", - company_id: "58a430d35458202d41b1e65b", - }); - expect(response).toEqual({ - type: "company", - id: "6762f0a01bb69f9f2193bb44", - name: "company8", - app_id: "this_is_an_id205_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537376, - created_at: 1734537376, - updated_at: 1734537377, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - }); - }); - - test("detachContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/companies/company_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.detachContact({ - contact_id: "contact_id", - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("detachContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/companies/company_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.companies.detachContact({ - contact_id: "contact_id", - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/contacts.test.ts b/tests/wire/contacts.test.ts deleted file mode 100644 index 2f74a99a..00000000 --- a/tests/wire/contacts.test.ts +++ /dev/null @@ -1,2871 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("ContactsClient", () => { - test("listAttachedCompanies (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, - }, - ], - total_count: 1, - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - }; - server - .mockEndpoint({ once: false }) - .get("/contacts/63a07ddf05a32042dffac965/companies") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: true, - monthly_spend: 155.5, - team_mates: 9, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - }; - const page = await client.contacts.listAttachedCompanies({ - contact_id: "63a07ddf05a32042dffac965", - page: 1, - per_page: 1, - }); - - expect(expected.companies).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.companies).toEqual(nextPage.data); - }); - - test("listAttachedCompanies (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/contacts/contact_id/companies") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedCompanies({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedCompanies (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/contacts/contact_id/companies") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedCompanies({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAttachedSegments (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/segments") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.listAttachedSegments({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }); - }); - - test("listAttachedSegments (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedSegments({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedSegments (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedSegments({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAttachedSubscriptions (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/subscriptions") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.listAttachedSubscriptions({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }); - }); - - test("listAttachedSubscriptions (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedSubscriptions({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedSubscriptions (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedSubscriptions({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("attachSubscription (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "37846", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.attachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscription (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "37846", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.attachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscription (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "invalid_id", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.attachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - id: "invalid_id", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscription (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", consent_type: "consent_type" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/contact_id/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.attachSubscription({ - contact_id: "contact_id", - id: "id", - consent_type: "consent_type", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("attachSubscription (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", consent_type: "consent_type" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.attachSubscription({ - contact_id: "contact_id", - id: "id", - consent_type: "consent_type", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("detachSubscription (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "subscription", - id: "122", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .delete("/contacts/63a07ddf05a32042dffac965/subscriptions/37846") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.detachSubscription({ - contact_id: "63a07ddf05a32042dffac965", - subscription_id: "37846", - }); - expect(response).toEqual({ - type: "subscription", - id: "122", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("detachSubscription (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/subscriptions/subscription_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.detachSubscription({ - contact_id: "contact_id", - subscription_id: "subscription_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("detachSubscription (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/subscriptions/subscription_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.detachSubscription({ - contact_id: "contact_id", - subscription_id: "subscription_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("listAttachedTags (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/tags") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.listAttachedTags({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }); - }); - - test("listAttachedTags (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedTags({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("listAttachedTags (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.listAttachedTags({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.find({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.find({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io", name: "joe bloggs" }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.update({ - contact_id: "63a07ddf05a32042dffac965", - email: "joebloggs@intercom.io", - name: "joe bloggs", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { custom_attributes: { order: ["21"] } }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { order_number: "ORDER-12345", total_amount: 99.99 }, - type: "Order", - }, - ], - }, - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.update({ - contact_id: "63a07ddf05a32042dffac965", - custom_attributes: { - order: ["21"], - }, - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { - order_number: "ORDER-12345", - total_amount: 99.99, - }, - type: "Order", - }, - ], - }, - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/contacts/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.update({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", deleted: true }; - server - .mockEndpoint() - .delete("/contacts/contact_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.delete({ - contact_id: "contact_id", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - deleted: true, - }); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.delete({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("mergeLeadInUser (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; - const rawResponseBody = { - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.mergeLeadInUser({ - from: "6762f0d51bb69f9f2193bb7f", - into: "6762f0d51bb69f9f2193bb80", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("mergeLeadInUser (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.mergeLeadInUser(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("search (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 0, - }, - }; - server - .mockEndpoint({ once: false }) - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 0, - }, - }; - const page = await client.contacts.search({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("search (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { query: {} }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.search({ - query: {}, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "id", - external_id: "external_id", - workspace_id: "workspace_id", - role: "role", - email: "email", - email_domain: "email_domain", - phone: "phone", - name: "name", - owner_id: 1, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1, - updated_at: 1, - signed_up_at: 1, - last_seen_at: 1, - last_replied_at: 1, - last_contacted_at: 1, - last_email_opened_at: 1, - last_email_clicked_at: 1, - language_override: "language_override", - browser: "browser", - browser_version: "browser_version", - browser_language: "browser_language", - os: "os", - android_app_name: "android_app_name", - android_app_version: "android_app_version", - android_device: "android_device", - android_os_version: "android_os_version", - android_sdk_version: "android_sdk_version", - android_last_seen_at: 1, - ios_app_name: "ios_app_name", - ios_app_version: "ios_app_version", - ios_device: "ios_device", - ios_os_version: "ios_os_version", - ios_sdk_version: "ios_sdk_version", - ios_last_seen_at: 1, - custom_attributes: { custom_attributes: { key: "value" } }, - avatar: "avatar", - tags: { - data: [ - { type: "type", id: "id", url: "url" }, - { type: "type", id: "id", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - notes: { - data: [ - { type: "type", id: "id", url: "url" }, - { type: "type", id: "id", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - companies: { - data: [ - { id: "id", type: "company", url: "url" }, - { id: "id", type: "company", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - location: { type: "type", country: "country", region: "region", city: "city" }, - social_profiles: { - data: [ - { type: "social_profile", name: "name", url: "url" }, - { type: "social_profile", name: "name", url: "url" }, - ], - }, - }, - { - type: "contact", - id: "id", - external_id: "external_id", - workspace_id: "workspace_id", - role: "role", - email: "email", - email_domain: "email_domain", - phone: "phone", - name: "name", - owner_id: 1, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1, - updated_at: 1, - signed_up_at: 1, - last_seen_at: 1, - last_replied_at: 1, - last_contacted_at: 1, - last_email_opened_at: 1, - last_email_clicked_at: 1, - language_override: "language_override", - browser: "browser", - browser_version: "browser_version", - browser_language: "browser_language", - os: "os", - android_app_name: "android_app_name", - android_app_version: "android_app_version", - android_device: "android_device", - android_os_version: "android_os_version", - android_sdk_version: "android_sdk_version", - android_last_seen_at: 1, - ios_app_name: "ios_app_name", - ios_app_version: "ios_app_version", - ios_device: "ios_device", - ios_os_version: "ios_os_version", - ios_sdk_version: "ios_sdk_version", - ios_last_seen_at: 1, - custom_attributes: { custom_attributes: { key: "value" } }, - avatar: "avatar", - tags: { - data: [ - { type: "type", id: "id", url: "url" }, - { type: "type", id: "id", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - notes: { - data: [ - { type: "type", id: "id", url: "url" }, - { type: "type", id: "id", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - companies: { - data: [ - { id: "id", type: "company", url: "url" }, - { id: "id", type: "company", url: "url" }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - location: { type: "type", country: "country", region: "region", city: "city" }, - social_profiles: { - data: [ - { type: "social_profile", name: "name", url: "url" }, - { type: "social_profile", name: "name", url: "url" }, - ], - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 1, starting_after: "starting_after" }, - per_page: 1, - total_pages: 1, - }, - }; - server - .mockEndpoint({ once: false }) - .get("/contacts") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - data: [ - { - type: "contact", - id: "id", - external_id: "external_id", - workspace_id: "workspace_id", - role: "role", - email: "email", - email_domain: "email_domain", - phone: "phone", - name: "name", - owner_id: 1, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1, - updated_at: 1, - signed_up_at: 1, - last_seen_at: 1, - last_replied_at: 1, - last_contacted_at: 1, - last_email_opened_at: 1, - last_email_clicked_at: 1, - language_override: "language_override", - browser: "browser", - browser_version: "browser_version", - browser_language: "browser_language", - os: "os", - android_app_name: "android_app_name", - android_app_version: "android_app_version", - android_device: "android_device", - android_os_version: "android_os_version", - android_sdk_version: "android_sdk_version", - android_last_seen_at: 1, - ios_app_name: "ios_app_name", - ios_app_version: "ios_app_version", - ios_device: "ios_device", - ios_os_version: "ios_os_version", - ios_sdk_version: "ios_sdk_version", - ios_last_seen_at: 1, - custom_attributes: { - custom_attributes: { - key: "value", - }, - }, - avatar: "avatar", - tags: { - data: [ - { - type: "type", - id: "id", - url: "url", - }, - { - type: "type", - id: "id", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - notes: { - data: [ - { - type: "type", - id: "id", - url: "url", - }, - { - type: "type", - id: "id", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - companies: { - data: [ - { - id: "id", - type: "company", - url: "url", - }, - { - id: "id", - type: "company", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - location: { - type: "type", - country: "country", - region: "region", - city: "city", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "name", - url: "url", - }, - { - type: "social_profile", - name: "name", - url: "url", - }, - ], - }, - }, - { - type: "contact", - id: "id", - external_id: "external_id", - workspace_id: "workspace_id", - role: "role", - email: "email", - email_domain: "email_domain", - phone: "phone", - name: "name", - owner_id: 1, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1, - updated_at: 1, - signed_up_at: 1, - last_seen_at: 1, - last_replied_at: 1, - last_contacted_at: 1, - last_email_opened_at: 1, - last_email_clicked_at: 1, - language_override: "language_override", - browser: "browser", - browser_version: "browser_version", - browser_language: "browser_language", - os: "os", - android_app_name: "android_app_name", - android_app_version: "android_app_version", - android_device: "android_device", - android_os_version: "android_os_version", - android_sdk_version: "android_sdk_version", - android_last_seen_at: 1, - ios_app_name: "ios_app_name", - ios_app_version: "ios_app_version", - ios_device: "ios_device", - ios_os_version: "ios_os_version", - ios_sdk_version: "ios_sdk_version", - ios_last_seen_at: 1, - custom_attributes: { - custom_attributes: { - key: "value", - }, - }, - avatar: "avatar", - tags: { - data: [ - { - type: "type", - id: "id", - url: "url", - }, - { - type: "type", - id: "id", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - notes: { - data: [ - { - type: "type", - id: "id", - url: "url", - }, - { - type: "type", - id: "id", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - companies: { - data: [ - { - id: "id", - type: "company", - url: "url", - }, - { - id: "id", - type: "company", - url: "url", - }, - ], - url: "url", - total_count: 1, - has_more: true, - }, - location: { - type: "type", - country: "country", - region: "region", - city: "city", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "name", - url: "url", - }, - { - type: "social_profile", - name: "name", - url: "url", - }, - ], - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 1, - starting_after: "starting_after", - }, - per_page: 1, - total_pages: 1, - }, - }; - const page = await client.contacts.list(); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/contacts") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io" }; - const rawResponseBody = { - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.create({ - email: "joebloggs@intercom.io", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "email" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.create({ - email: "email", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("ShowContactByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.showContactByExternalId({ - external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("ShowContactByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/external_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.contacts.showContactByExternalId({ - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("archive", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/archive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.archive({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: true, - }); - }); - - test("unarchive", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: false }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/unarchive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.unarchive({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: false, - }); - }); - - test("BlockContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", blocked: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/block") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.contacts.blockContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - blocked: true, - }); - }); -}); diff --git a/tests/wire/conversations.test.ts b/tests/wire/conversations.test.ts deleted file mode 100644 index 77dab803..00000000 --- a/tests/wire/conversations.test.ts +++ /dev/null @@ -1,12610 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("ConversationsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "471", - title: "Conversation Title", - created_at: 1734537460, - updated_at: 1734537460, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], - }, - conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, - source: { - type: "conversation", - id: "403918320", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267628", - name: "Ciaran166 Lee", - email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f0f31bb69f9f2193bb8b", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - }; - server - .mockEndpoint({ once: false }) - .get("/conversations") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "471", - title: "Conversation Title", - created_at: 1734537460, - updated_at: 1734537460, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - }, - source: { - type: "conversation", - id: "403918320", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267628", - name: "Ciaran166 Lee", - email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f0f31bb69f9f2193bb8b", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - }; - const page = await client.conversations.list({ - per_page: 1, - starting_after: "starting_after", - }); - - expect(expected.conversations).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.conversations).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/conversations") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("list (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/conversations") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.list(); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "user", id: "6762f11b1bb69f9f2193bba3" }, body: "Hello there" }; - const rawResponseBody = { - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.create({ - from: { - type: "user", - id: "6762f11b1bb69f9f2193bba3", - }, - body: "Hello there", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "user", id: "123_doesnt_exist" }, body: "Hello there" }; - const rawResponseBody = { - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.create({ - from: { - type: "user", - id: "123_doesnt_exist", - }, - body: "Hello there", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.create({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.create({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.create({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "conversation", - id: "503", - title: "Conversation Title", - created_at: 1734537511, - updated_at: 1734537511, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918334", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267645", - name: "Ciaran176 Lee", - email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1261bb69f9f2193bba7", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - assigned_to: { type: "contact", id: "1a2b3c" }, - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_started", - body: "

Okay!

", - created_at: 1740141842, - updated_at: 1740141842, - notified_at: 1740141842, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { action: { name: "Jira Create Issue" } }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1740141851, - updated_at: 1740141851, - notified_at: 1740141851, - author: { - type: "bot", - id: "278", - name: "Fin", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { attribute: { name: "jira_issue_key" }, value: { name: "PROJ-007" } }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_finished", - body: "

Okay!

", - created_at: 1740141857, - updated_at: 1740141857, - notified_at: 1740141857, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "closed", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { action: { name: "Jira Create Issue", result: "success" } }, - app_package_code: "test-integration", - }, - ], - total_count: 4, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server.mockEndpoint().get("/conversations/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.conversations.find({ - conversation_id: "123", - display_as: "plaintext", - include_translations: true, - }); - expect(response).toEqual({ - type: "conversation", - id: "503", - title: "Conversation Title", - created_at: 1734537511, - updated_at: 1734537511, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918334", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267645", - name: "Ciaran176 Lee", - email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1261bb69f9f2193bba7", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - assigned_to: { - type: "contact", - id: "1a2b3c", - }, - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_started", - body: "

Okay!

", - created_at: 1740141842, - updated_at: 1740141842, - notified_at: 1740141842, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - action: { - name: "Jira Create Issue", - }, - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1740141851, - updated_at: 1740141851, - notified_at: 1740141851, - author: { - type: "bot", - id: "278", - name: "Fin", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - attribute: { - name: "jira_issue_key", - }, - value: { - name: "PROJ-007", - }, - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_finished", - body: "

Okay!

", - created_at: 1740141857, - updated_at: 1740141857, - notified_at: 1740141857, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "closed", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - action: { - name: "Jira Create Issue", - result: "success", - }, - }, - app_package_code: "test-integration", - }, - ], - total_count: 4, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/conversations/conversation_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.find({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/conversations/conversation_id") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.find({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("find (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/conversations/conversation_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.find({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - read: true, - title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.update({ - conversation_id: "conversation_id", - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1301bb69f9f2193bbab", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { custom_attributes: { order: {} } }; - const rawResponseBody = { - type: "conversation", - id: "508", - title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1341bb69f9f2193bbac", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }, - ], - }, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 0, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.update({ - conversation_id: "conversation_id", - display_as: "plaintext", - custom_attributes: { - order: {}, - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "508", - title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1341bb69f9f2193bbac", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }, - ], - }, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 0, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - read: true, - title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.update({ - conversation_id: "conversation_id", - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1301bb69f9f2193bbab", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.update({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.update({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("update (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/conversations/conversation_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.update({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("deleteConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "512", object: "conversation", deleted: true }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.deleteConversation({ - conversation_id: 1, - }); - expect(response).toEqual({ - id: "512", - object: "conversation", - deleted: true, - }); - }); - - test("deleteConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.deleteConversation({ - conversation_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.deleteConversation({ - conversation_id: 1, - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("search", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], - }, - conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267691", - name: "Ciaran210 Lee", - email: "admin210@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f14a1bb69f9f2193bbb3", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 1, - }, - }; - server - .mockEndpoint({ once: false }) - .post("/conversations/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267691", - name: "Ciaran210 Lee", - email: "admin210@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f14a1bb69f9f2193bbb3", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 1, - }, - }; - const page = await client.conversations.search({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - - expect(expected.conversations).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.conversations).toEqual(nextPage.data); - }); - - test("reply (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_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", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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" }, - ], - }; - const rawResponseBody = { - type: "conversation", - id: "526", - title: "Conversation Title", - created_at: 1734537567, - updated_at: 1734537568, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918351", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f15e1bb69f9f2193bbbd", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "134", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537568, - updated_at: 1734537568, - notified_at: 1734537568, - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_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", - }, - ], - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "526", - title: "Conversation Title", - created_at: 1734537567, - updated_at: 1734537568, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918351", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f15e1bb69f9f2193bbbd", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "134", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537568, - updated_at: 1734537568, - notified_at: 1734537568, - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "body", - reply_options: [{ text: "Yes", uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" }], - intercom_user_id: "6762f1621bb69f9f2193bbbe", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_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", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1661bb69f9f2193bbbf", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1661bb69f9f2193bbbf", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }; - const rawResponseBody = { - type: "conversation", - id: "525", - title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918350", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f15b1bb69f9f2193bbbc", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "133", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "525", - title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918350", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f15b1bb69f9f2193bbbc", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "133", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }; - const rawResponseBody = { - type: "conversation", - id: "527", - title: "Conversation Title", - created_at: 1734537571, - updated_at: 1734537572, - waiting_since: 1734537572, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918352", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267700", - name: "Ciaran215 Lee", - email: "admin215@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1621bb69f9f2193bbbe", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537572, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "135", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537572, - updated_at: 1734537572, - notified_at: 1734537572, - author: { - type: "user", - id: "6762f1621bb69f9f2193bbbe", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.reply({ - conversation_id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "527", - title: "Conversation Title", - created_at: 1734537571, - updated_at: 1734537572, - waiting_since: 1734537572, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918352", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267700", - name: "Ciaran215 Lee", - email: "admin215@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1621bb69f9f2193bbbe", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537572, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "135", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537572, - updated_at: 1734537572, - notified_at: 1734537572, - author: { - type: "user", - id: "6762f1621bb69f9f2193bbbe", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("reply (9)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.reply({ - conversation_id: "conversation_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("reply (10)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.reply({ - conversation_id: "conversation_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("reply (11)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.reply({ - conversation_id: "conversation_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("manage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; - const rawResponseBody = { - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.manage({ - conversation_id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f16e1bb69f9f2193bbc2", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "snoozed", admin_id: "5017691", snoozed_until: 1673609604 }; - const rawResponseBody = { - type: "conversation", - id: "532", - title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, - open: true, - state: "snoozed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918357", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1711bb69f9f2193bbc3", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.manage({ - conversation_id: "123", - body: { - message_type: "snoozed", - admin_id: "5017691", - snoozed_until: 1673609604, - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "532", - title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, - open: true, - state: "snoozed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918357", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1711bb69f9f2193bbc3", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "open", admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918358", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1781bb69f9f2193bbc8", external_id: "74" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.manage({ - conversation_id: "123", - body: { - message_type: "open", - admin_id: "5017690", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918358", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1781bb69f9f2193bbc8", - external_id: "74", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "assignment", type: "admin", admin_id: "12345", assignee_id: "4324241" }; - const rawResponseBody = { - type: "conversation", - id: "542", - title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918361", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1831bb69f9f2193bbcc", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", - body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { type: "admin", id: "991267715" }, - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.manage({ - conversation_id: "123", - body: { - message_type: "assignment", - type: "admin", - admin_id: "12345", - assignee_id: "4324241", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "542", - title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918361", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1831bb69f9f2193bbcc", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", - body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { - type: "admin", - id: "991267715", - }, - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; - const rawResponseBody = { - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.manage({ - conversation_id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f16e1bb69f9f2193bbc2", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manage (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.manage({ - conversation_id: "conversation_id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("manage (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.manage({ - conversation_id: "conversation_id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("manage (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.manage({ - conversation_id: "conversation_id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("attachContactAsAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19b1bb69f9f2193bbd4" } }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.attachContactAsAdmin({ - conversation_id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19b1bb69f9f2193bbd4", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("attachContactAsAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19e1bb69f9f2193bbd5" } }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.attachContactAsAdmin({ - conversation_id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19e1bb69f9f2193bbd5", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("attachContactAsAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.attachContactAsAdmin({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("attachContactAsAdmin (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.attachContactAsAdmin({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("attachContactAsAdmin (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.attachContactAsAdmin({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("detachContactAsAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.detachContactAsAdmin({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactAsAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.detachContactAsAdmin({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactAsAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.detachContactAsAdmin({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactAsAdmin (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.detachContactAsAdmin({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactAsAdmin (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.detachContactAsAdmin({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("detachContactAsAdmin (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.detachContactAsAdmin({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("detachContactAsAdmin (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.detachContactAsAdmin({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("detachContactAsAdmin (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.detachContactAsAdmin({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("redactConversationPart (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", - }; - const rawResponseBody = { - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", - }); - expect(response).toEqual({ - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1f81bb69f9f2193bc09", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("redactConversationPart (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", - }; - const rawResponseBody = { - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", - }); - expect(response).toEqual({ - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1f81bb69f9f2193bc09", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("redactConversationPart (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("redactConversationPart (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.redactConversationPart({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("convertToTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "53" }; - const rawResponseBody = { - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { key: "value" }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.convertToTicket({ - conversation_id: 1, - ticket_type_id: "53", - }); - expect(response).toEqual({ - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { - key: "value", - }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2041bb69f9f2193bc0c", - external_id: "70", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }); - }); - - test("convertToTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "54" }; - const rawResponseBody = { - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { key: "value" }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.convertToTicket({ - conversation_id: 1, - ticket_type_id: "54", - }); - expect(response).toEqual({ - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { - key: "value", - }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2041bb69f9f2193bc0c", - external_id: "70", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }); - }); - - test("convertToTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.convertToTicket({ - conversation_id: 1, - ticket_type_id: "ticket_type_id", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("runAssignmentRules (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "conversation", - id: "409", - title: "Conversation Title", - created_at: 1719492880, - updated_at: 1719492881, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918285", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267623", - name: "Ciaran197 Lee", - email: "admin197@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "667d61108a68186f43bafe09", external_id: "70" }], - }, - teammates: { type: "admin.list", admins: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "107", - part_type: "default_assignment", - body: "

Okay!

", - created_at: 1719492881, - updated_at: 1719492881, - notified_at: 1719492881, - assigned_to: { type: "nobody_admin", id: "1a2b3c" }, - author: { - type: "bot", - id: "991267624", - name: "Operator", - email: "operator+this_is_an_id364_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/run_assignment_rules") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.conversations.runAssignmentRules({ - conversation_id: "123", - }); - expect(response).toEqual({ - type: "conversation", - id: "409", - title: "Conversation Title", - created_at: 1719492880, - updated_at: 1719492881, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918285", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267623", - name: "Ciaran197 Lee", - email: "admin197@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "667d61108a68186f43bafe09", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - admins: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "107", - part_type: "default_assignment", - body: "

Okay!

", - created_at: 1719492881, - updated_at: 1719492881, - notified_at: 1719492881, - assigned_to: { - type: "nobody_admin", - id: "1a2b3c", - }, - author: { - type: "bot", - id: "991267624", - name: "Operator", - email: "operator+this_is_an_id364_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("runAssignmentRules (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/run_assignment_rules") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.runAssignmentRules({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("runAssignmentRules (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/run_assignment_rules") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.runAssignmentRules({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("runAssignmentRules (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/run_assignment_rules") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.conversations.runAssignmentRules({ - conversation_id: "conversation_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/customChannelEvents.test.ts b/tests/wire/customChannelEvents.test.ts deleted file mode 100644 index f259cba1..00000000 --- a/tests/wire/customChannelEvents.test.ts +++ /dev/null @@ -1,790 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("CustomChannelEventsClient", () => { - test("notifyNewConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyNewConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyNewConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyNewConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyNewConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyNewMessage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyNewMessage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyNewMessage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyNewMessage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyNewMessage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyQuickReplySelected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.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", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyQuickReplySelected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyQuickReplySelected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyQuickReplySelected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyQuickReplySelected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); - - test("notifyAttributeCollected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - expect(response).toEqual({ - external_conversation_id: "external_conversation_id", - conversation_id: "conversation_id", - external_contact_id: "external_contact_id", - contact_id: "contact_id", - }); - }); - - test("notifyAttributeCollected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("notifyAttributeCollected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("notifyAttributeCollected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("notifyAttributeCollected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/customObjectInstances.test.ts b/tests/wire/customObjectInstances.test.ts deleted file mode 100644 index 8d12db82..00000000 --- a/tests/wire/customObjectInstances.test.ts +++ /dev/null @@ -1,475 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("CustomObjectInstancesClient", () => { - test("getCustomObjectInstancesByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .get("/custom_object_instances/Order") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - external_id: "external_id", - }); - expect(response).toEqual({ - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("getCustomObjectInstancesByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("getCustomObjectInstancesByExternalId (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("createCustomObjectInstances (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - const rawResponseBody = { - id: "22", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1734537745, - updated_at: 1734537745, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .post("/custom_object_instances/Order") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.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", - }, - }); - expect(response).toEqual({ - id: "22", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1734537745, - updated_at: 1734537745, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("createCustomObjectInstances (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_object_instances/custom_object_type_identifier") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.createCustomObjectInstances({ - custom_object_type_identifier: "custom_object_type_identifier", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("createCustomObjectInstances (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_object_instances/custom_object_type_identifier") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.createCustomObjectInstances({ - custom_object_type_identifier: "custom_object_type_identifier", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("deleteCustomObjectInstancesById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { object: "Order", id: "26", deleted: true }; - server - .mockEndpoint() - .delete("/custom_object_instances/Order") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - external_id: "external_id", - }); - expect(response).toEqual({ - object: "Order", - id: "26", - deleted: true, - }); - }); - - test("deleteCustomObjectInstancesById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteCustomObjectInstancesById (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("getCustomObjectInstancesById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "25", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537750, - updated_at: 1734537750, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .get("/custom_object_instances/Order/custom_object_instance_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - custom_object_instance_id: "custom_object_instance_id", - }); - expect(response).toEqual({ - id: "25", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537750, - updated_at: 1734537750, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("getCustomObjectInstancesById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier/custom_object_instance_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - custom_object_instance_id: "custom_object_instance_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("getCustomObjectInstancesById (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier/custom_object_instance_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - custom_object_instance_id: "custom_object_instance_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("deleteCustomObjectInstancesByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { object: "Order", id: "26", deleted: true }; - server - .mockEndpoint() - .delete("/custom_object_instances/Order/custom_object_instance_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - custom_object_instance_id: "custom_object_instance_id", - }); - expect(response).toEqual({ - object: "Order", - id: "26", - deleted: true, - }); - }); - - test("deleteCustomObjectInstancesByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier/custom_object_instance_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - custom_object_instance_id: "custom_object_instance_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteCustomObjectInstancesByExternalId (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier/custom_object_instance_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - custom_object_instance_id: "custom_object_instance_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/dataAttributes.test.ts b/tests/wire/dataAttributes.test.ts deleted file mode 100644 index b5b723af..00000000 --- a/tests/wire/dataAttributes.test.ts +++ /dev/null @@ -1,1515 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("DataAttributesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "name", - label: "Company name", - description: "The name of a company", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "company_id", - full_name: "company_id", - label: "Company ID", - description: "A number identifying a company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "last_request_at", - full_name: "last_request_at", - label: "Company last seen", - description: "The last day anyone from a company visited your site or app", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "remote_created_at", - full_name: "remote_created_at", - label: "Company created at", - description: "The day a company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "user_count", - full_name: "user_count", - label: "People", - description: "The number of people in a company", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "session_count", - full_name: "session_count", - label: "Company web sessions", - description: "All visits from anyone in a company to your product's site or app", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "plan.name", - label: "Plan", - description: "A specific plan or level within your product that companies have signed up to", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "monthly_spend", - full_name: "monthly_spend", - label: "Monthly Spend", - description: "The monthly revenue you receive from a company", - data_type: "float", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "size", - full_name: "size", - label: "Company size", - description: "The number of people employed in this company, expressed as a single number", - data_type: "integer", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "industry", - full_name: "industry", - label: "Company industry", - description: "The category or domain this company belongs to e.g. 'ecommerce' or 'SaaS'", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "website", - full_name: "website", - label: "Company website", - description: "The web address for the company's primary marketing site", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 34, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: - "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537753, - updated_at: 1734537753, - admin_id: "991267784", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "id", - label: "ID", - description: "The Intercom defined id representing the company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "created_at", - full_name: "created_at", - label: "Created at", - description: "The time the company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "updated_at", - full_name: "updated_at", - label: "Updated at", - description: "The last time the company was updated", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "plan.id", - label: "Plan ID", - description: "The Intercom defined id representing the plan", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "app_id", - full_name: "app_id", - label: "App ID", - description: "The Intercom defined id representing the app", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - ], - }; - server.mockEndpoint().get("/data_attributes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.dataAttributes.list({ - model: "contact", - include_archived: true, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "name", - label: "Company name", - description: "The name of a company", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "company_id", - full_name: "company_id", - label: "Company ID", - description: "A number identifying a company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "last_request_at", - full_name: "last_request_at", - label: "Company last seen", - description: "The last day anyone from a company visited your site or app", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "remote_created_at", - full_name: "remote_created_at", - label: "Company created at", - description: "The day a company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "user_count", - full_name: "user_count", - label: "People", - description: "The number of people in a company", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "session_count", - full_name: "session_count", - label: "Company web sessions", - description: "All visits from anyone in a company to your product's site or app", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "plan.name", - label: "Plan", - description: "A specific plan or level within your product that companies have signed up to", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "monthly_spend", - full_name: "monthly_spend", - label: "Monthly Spend", - description: "The monthly revenue you receive from a company", - data_type: "float", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "size", - full_name: "size", - label: "Company size", - description: "The number of people employed in this company, expressed as a single number", - data_type: "integer", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "industry", - full_name: "industry", - label: "Company industry", - description: "The category or domain this company belongs to e.g. 'ecommerce' or 'SaaS'", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "website", - full_name: "website", - label: "Company website", - description: "The web address for the company's primary marketing site", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 34, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: - "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537753, - updated_at: 1734537753, - admin_id: "991267784", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "id", - label: "ID", - description: "The Intercom defined id representing the company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "created_at", - full_name: "created_at", - label: "Created at", - description: "The time the company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "updated_at", - full_name: "updated_at", - label: "Updated at", - description: "The last time the company was updated", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "plan.id", - label: "Plan ID", - description: "The Intercom defined id representing the plan", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "app_id", - full_name: "app_id", - label: "App ID", - description: "The Intercom defined id representing the app", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/data_attributes").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.dataAttributes.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { data_type: "string" }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - data_type: "string", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { data_type: "integer" }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - data_type: "integer", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { data_type: "string" }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - data_type: "string", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { data_type: "string" }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - data_type: "string", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { data_type: "string" }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - data_type: "string", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{ value: "1-10" }] }; - const rawResponseBody = { - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.create({ - options: [ - { - value: "1-10", - }, - ], - }); - expect(response).toEqual({ - type: "data_attribute", - id: 37, - model: "company", - name: "Mithril Shirt", - full_name: "custom_attributes.Mithril Shirt", - label: "Mithril Shirt", - description: "Whether the user is a paid subscriber.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: false, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537756, - updated_at: 1734537756, - admin_id: "991267786", - }); - }); - - test("create (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.create({ - options: [{}, {}], - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.create({ - options: [{}, {}], - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{ value: "1-10" }, { value: "11-20" }] }; - const rawResponseBody = { - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [ - { - value: "1-10", - }, - { - value: "11-20", - }, - ], - }, - }); - expect(response).toEqual({ - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{ value: "1-10" }, { value: "11-50" }] }; - const rawResponseBody = { - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [ - { - value: "1-10", - }, - { - value: "11-50", - }, - ], - }, - }); - expect(response).toEqual({ - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{ value: "1-10" }, { value: "11-20" }] }; - const rawResponseBody = { - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [ - { - value: "1-10", - }, - { - value: "11-20", - }, - ], - }, - }); - expect(response).toEqual({ - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { description: "Trying to archieve", archived: true }; - const rawResponseBody = { - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - description: "Trying to archieve", - archived: true, - }, - }); - expect(response).toEqual({ - type: "data_attribute", - id: 44, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: "Just a plain old ring", - data_type: "string", - options: ["1-10", "11-20"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537762, - updated_at: 1734537763, - admin_id: "991267793", - }); - }); - - test("update (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [{}, {}], - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("update (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [{}, {}], - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [{}, {}], - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { options: [{}, {}] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataAttributes.update({ - data_attribute_id: 1, - body: { - options: [{}, {}], - }, - }); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/dataExport.test.ts b/tests/wire/dataExport.test.ts deleted file mode 100644 index a141d93e..00000000 --- a/tests/wire/dataExport.test.ts +++ /dev/null @@ -1,273 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("DataExportClient", () => { - test("exportReportingData (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - job_identifier: "job1", - status: "complete", - download_url: "", - download_expires_at: "", - }; - server - .mockEndpoint() - .get("/export/reporting_data/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataExport.exportReportingData({ - job_identifier: "job_identifier", - app_id: "app_id", - client_id: "client_id", - }); - expect(response).toEqual({ - job_identifier: "job1", - status: "complete", - download_url: "", - download_expires_at: "", - }); - }); - - test("exportReportingData (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { job_identifier: "job1", status: "failed", download_url: "", download_expires_at: "" }; - server - .mockEndpoint() - .get("/export/reporting_data/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataExport.exportReportingData({ - job_identifier: "job_identifier", - app_id: "app_id", - client_id: "client_id", - }); - expect(response).toEqual({ - job_identifier: "job1", - status: "failed", - download_url: "", - download_expires_at: "", - }); - }); - - test("exportReportingData (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/export/reporting_data/job_identifier") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataExport.exportReportingData({ - job_identifier: "job_identifier", - app_id: "app_id", - client_id: "client_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("downloadReportingDataExport (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server - .mockEndpoint() - .get("/download/reporting_data/job_identifier") - .header("Accept", "application/octet-stream") - .respondWith() - .statusCode(200) - .build(); - - const response = await client.dataExport.downloadReportingDataExport({ - job_identifier: "job_identifier", - app_id: "app_id", - }); - expect(response).toEqual(undefined); - }); - - test("downloadReportingDataExport (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/download/reporting_data/job_identifier") - .header("Accept", "application/octet-stream") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.dataExport.downloadReportingDataExport({ - job_identifier: "job_identifier", - app_id: "app_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("create", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { created_at_after: 1734519776, created_at_before: 1734537776 }; - const rawResponseBody = { - job_identifier: "al9w983lwu88w1fd", - status: "pending", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .post("/export/content/data") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataExport.create({ - created_at_after: 1734519776, - created_at_before: 1734537776, - }); - expect(response).toEqual({ - job_identifier: "al9w983lwu88w1fd", - status: "pending", - download_expires_at: "", - download_url: "", - }); - }); - - test("find", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - job_identifier: "braxwk3j039t6txy", - status: "pending", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .get("/export/content/data/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataExport.find({ - job_identifier: "job_identifier", - }); - expect(response).toEqual({ - job_identifier: "braxwk3j039t6txy", - status: "pending", - download_expires_at: "", - download_url: "", - }); - }); - - test("cancel", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - job_identifier: "v134nyc2bku9hj91", - status: "canceled", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .post("/export/cancel/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.dataExport.cancel({ - job_identifier: "job_identifier", - }); - expect(response).toEqual({ - job_identifier: "v134nyc2bku9hj91", - status: "canceled", - download_expires_at: "", - download_url: "", - }); - }); - - test("download", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().get("/download/content/data/job_identifier").respondWith().statusCode(200).build(); - - const response = await client.dataExport.download({ - job_identifier: "job_identifier", - }); - expect(response).toEqual(undefined); - }); -}); diff --git a/tests/wire/events.test.ts b/tests/wire/events.test.ts deleted file mode 100644 index b6b4756a..00000000 --- a/tests/wire/events.test.ts +++ /dev/null @@ -1,169 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("EventsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "event.summary", - email: "user26@email.com", - intercom_user_id: "6762f22b1bb69f9f2193bc12", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - events: [ - { - name: "placed-order", - first: "2014-01-16T23:12:21.000+00:00", - last: "2014-01-16T23:12:21.000+00:00 ", - count: 1, - description: "A user placed an order", - }, - ], - }; - server.mockEndpoint().get("/events").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.events.list({ - user_id: "user_id", - intercom_user_id: "intercom_user_id", - email: "email", - type: "type", - summary: true, - per_page: 1, - }); - expect(response).toEqual({ - type: "event.summary", - email: "user26@email.com", - intercom_user_id: "6762f22b1bb69f9f2193bc12", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - events: [ - { - name: "placed-order", - first: "2014-01-16T23:12:21.000+00:00", - last: "2014-01-16T23:12:21.000+00:00 ", - count: 1, - description: "A user placed an order", - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/events").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.events.list({ - type: "type", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - event_name: "invited-friend", - created_at: 1671028894, - }; - - server.mockEndpoint().post("/events").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - - const response = await client.events.create({ - id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - event_name: "invited-friend", - created_at: 1671028894, - }); - expect(response).toEqual(undefined); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", event_name: "event_name", created_at: 1 }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/events") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.events.create({ - id: "id", - event_name: "event_name", - created_at: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("summaries (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - - server.mockEndpoint().post("/events/summaries").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - - const response = await client.events.summaries(); - expect(response).toEqual(undefined); - }); - - test("summaries (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/events/summaries") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.events.summaries(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/export.test.ts b/tests/wire/export.test.ts deleted file mode 100644 index c7ff75eb..00000000 --- a/tests/wire/export.test.ts +++ /dev/null @@ -1,201 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("ExportClient", () => { - test("enqueueANewReportingDataExportJob (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000, - }; - const rawResponseBody = { - job_identifier: "job1", - status: "pending", - download_url: "download_url", - download_expires_at: "download_expires_at", - }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.export.enqueueANewReportingDataExportJob({ - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000, - }); - expect(response).toEqual({ - job_identifier: "job1", - status: "pending", - download_url: "download_url", - download_expires_at: "download_expires_at", - }); - }); - - test("enqueueANewReportingDataExportJob (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("enqueueANewReportingDataExportJob (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("enqueueANewReportingDataExportJob (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.TooManyRequestsError); - }); - - test("listAvailableDatasetsAndAttributes", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - id: "conversation", - name: "Conversation", - description: "Conversation-level details: status, channel, assignee.", - default_time_attribute_id: "conversation_started_at", - attributes: [{ id: "conversation_id", name: "Conversation ID" }], - }, - ], - }; - server - .mockEndpoint() - .get("/export/reporting_data/get_datasets") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.export.listAvailableDatasetsAndAttributes(); - expect(response).toEqual({ - type: "list", - data: [ - { - id: "conversation", - name: "Conversation", - description: "Conversation-level details: status, channel, assignee.", - default_time_attribute_id: "conversation_started_at", - attributes: [ - { - id: "conversation_id", - name: "Conversation ID", - }, - ], - }, - ], - }); - }); -}); diff --git a/tests/wire/helpCenters.test.ts b/tests/wire/helpCenters.test.ts deleted file mode 100644 index 6376c589..00000000 --- a/tests/wire/helpCenters.test.ts +++ /dev/null @@ -1,203 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("HelpCentersClient", () => { - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "93", - workspace_id: "this_is_an_id124_that_should_be_at_least_", - created_at: 1734537325, - updated_at: 1734537325, - identifier: "help-center-1", - website_turned_on: false, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.find({ - help_center_id: 1, - }); - expect(response).toEqual({ - id: "93", - workspace_id: "this_is_an_id124_that_should_be_at_least_", - created_at: 1734537325, - updated_at: 1734537325, - identifier: "help-center-1", - website_turned_on: false, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.find({ - help_center_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.find({ - help_center_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - id: "id", - workspace_id: "workspace_id", - created_at: 1, - updated_at: 1, - identifier: "identifier", - website_turned_on: true, - display_name: "display_name", - url: "url", - custom_domain: "custom_domain", - }, - { - id: "id", - workspace_id: "workspace_id", - created_at: 1, - updated_at: 1, - identifier: "identifier", - website_turned_on: true, - display_name: "display_name", - url: "url", - custom_domain: "custom_domain", - }, - ], - }; - server - .mockEndpoint({ once: false }) - .get("/help_center/help_centers") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - data: [ - { - id: "id", - workspace_id: "workspace_id", - created_at: 1, - updated_at: 1, - identifier: "identifier", - website_turned_on: true, - display_name: "display_name", - url: "url", - custom_domain: "custom_domain", - }, - { - id: "id", - workspace_id: "workspace_id", - created_at: 1, - updated_at: 1, - identifier: "identifier", - website_turned_on: true, - display_name: "display_name", - url: "url", - custom_domain: "custom_domain", - }, - ], - }; - const page = await client.helpCenters.list(); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/help_center/help_centers") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/helpCenters/collections.test.ts b/tests/wire/helpCenters/collections.test.ts deleted file mode 100644 index c32574f1..00000000 --- a/tests/wire/helpCenters/collections.test.ts +++ /dev/null @@ -1,2216 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CollectionsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "offset_pages", page: 1, next: "next", per_page: 1, total_pages: 1 }, - total_count: 1, - data: [ - { - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - created_at: 1, - updated_at: 1, - url: "url", - icon: "icon", - order: 1, - default_locale: "default_locale", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "name", description: "description" }, - bg: { type: "group_content", name: "name", description: "description" }, - bs: { type: "group_content", name: "name", description: "description" }, - ca: { type: "group_content", name: "name", description: "description" }, - cs: { type: "group_content", name: "name", description: "description" }, - da: { type: "group_content", name: "name", description: "description" }, - de: { type: "group_content", name: "name", description: "description" }, - el: { type: "group_content", name: "name", description: "description" }, - en: { type: "group_content", name: "name", description: "description" }, - es: { type: "group_content", name: "name", description: "description" }, - et: { type: "group_content", name: "name", description: "description" }, - fi: { type: "group_content", name: "name", description: "description" }, - fr: { type: "group_content", name: "name", description: "description" }, - he: { type: "group_content", name: "name", description: "description" }, - hr: { type: "group_content", name: "name", description: "description" }, - hu: { type: "group_content", name: "name", description: "description" }, - id: { type: "group_content", name: "name", description: "description" }, - it: { type: "group_content", name: "name", description: "description" }, - ja: { type: "group_content", name: "name", description: "description" }, - ko: { type: "group_content", name: "name", description: "description" }, - lt: { type: "group_content", name: "name", description: "description" }, - lv: { type: "group_content", name: "name", description: "description" }, - mn: { type: "group_content", name: "name", description: "description" }, - nb: { type: "group_content", name: "name", description: "description" }, - nl: { type: "group_content", name: "name", description: "description" }, - pl: { type: "group_content", name: "name", description: "description" }, - pt: { type: "group_content", name: "name", description: "description" }, - ro: { type: "group_content", name: "name", description: "description" }, - ru: { type: "group_content", name: "name", description: "description" }, - sl: { type: "group_content", name: "name", description: "description" }, - sr: { type: "group_content", name: "name", description: "description" }, - sv: { type: "group_content", name: "name", description: "description" }, - tr: { type: "group_content", name: "name", description: "description" }, - vi: { type: "group_content", name: "name", description: "description" }, - "pt-BR": { type: "group_content", name: "name", description: "description" }, - "zh-CN": { type: "group_content", name: "name", description: "description" }, - "zh-TW": { type: "group_content", name: "name", description: "description" }, - }, - parent_id: "parent_id", - help_center_id: 1, - }, - { - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - created_at: 1, - updated_at: 1, - url: "url", - icon: "icon", - order: 1, - default_locale: "default_locale", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "name", description: "description" }, - bg: { type: "group_content", name: "name", description: "description" }, - bs: { type: "group_content", name: "name", description: "description" }, - ca: { type: "group_content", name: "name", description: "description" }, - cs: { type: "group_content", name: "name", description: "description" }, - da: { type: "group_content", name: "name", description: "description" }, - de: { type: "group_content", name: "name", description: "description" }, - el: { type: "group_content", name: "name", description: "description" }, - en: { type: "group_content", name: "name", description: "description" }, - es: { type: "group_content", name: "name", description: "description" }, - et: { type: "group_content", name: "name", description: "description" }, - fi: { type: "group_content", name: "name", description: "description" }, - fr: { type: "group_content", name: "name", description: "description" }, - he: { type: "group_content", name: "name", description: "description" }, - hr: { type: "group_content", name: "name", description: "description" }, - hu: { type: "group_content", name: "name", description: "description" }, - id: { type: "group_content", name: "name", description: "description" }, - it: { type: "group_content", name: "name", description: "description" }, - ja: { type: "group_content", name: "name", description: "description" }, - ko: { type: "group_content", name: "name", description: "description" }, - lt: { type: "group_content", name: "name", description: "description" }, - lv: { type: "group_content", name: "name", description: "description" }, - mn: { type: "group_content", name: "name", description: "description" }, - nb: { type: "group_content", name: "name", description: "description" }, - nl: { type: "group_content", name: "name", description: "description" }, - pl: { type: "group_content", name: "name", description: "description" }, - pt: { type: "group_content", name: "name", description: "description" }, - ro: { type: "group_content", name: "name", description: "description" }, - ru: { type: "group_content", name: "name", description: "description" }, - sl: { type: "group_content", name: "name", description: "description" }, - sr: { type: "group_content", name: "name", description: "description" }, - sv: { type: "group_content", name: "name", description: "description" }, - tr: { type: "group_content", name: "name", description: "description" }, - vi: { type: "group_content", name: "name", description: "description" }, - "pt-BR": { type: "group_content", name: "name", description: "description" }, - "zh-CN": { type: "group_content", name: "name", description: "description" }, - "zh-TW": { type: "group_content", name: "name", description: "description" }, - }, - parent_id: "parent_id", - help_center_id: 1, - }, - ], - }; - server - .mockEndpoint({ once: false }) - .get("/help_center/collections") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "list", - pages: { - type: "offset_pages", - page: 1, - next: "next", - per_page: 1, - total_pages: 1, - }, - total_count: 1, - data: [ - { - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - created_at: 1, - updated_at: 1, - url: "url", - icon: "icon", - order: 1, - default_locale: "default_locale", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "name", - description: "description", - }, - bg: { - type: "group_content", - name: "name", - description: "description", - }, - bs: { - type: "group_content", - name: "name", - description: "description", - }, - ca: { - type: "group_content", - name: "name", - description: "description", - }, - cs: { - type: "group_content", - name: "name", - description: "description", - }, - da: { - type: "group_content", - name: "name", - description: "description", - }, - de: { - type: "group_content", - name: "name", - description: "description", - }, - el: { - type: "group_content", - name: "name", - description: "description", - }, - en: { - type: "group_content", - name: "name", - description: "description", - }, - es: { - type: "group_content", - name: "name", - description: "description", - }, - et: { - type: "group_content", - name: "name", - description: "description", - }, - fi: { - type: "group_content", - name: "name", - description: "description", - }, - fr: { - type: "group_content", - name: "name", - description: "description", - }, - he: { - type: "group_content", - name: "name", - description: "description", - }, - hr: { - type: "group_content", - name: "name", - description: "description", - }, - hu: { - type: "group_content", - name: "name", - description: "description", - }, - id: { - type: "group_content", - name: "name", - description: "description", - }, - it: { - type: "group_content", - name: "name", - description: "description", - }, - ja: { - type: "group_content", - name: "name", - description: "description", - }, - ko: { - type: "group_content", - name: "name", - description: "description", - }, - lt: { - type: "group_content", - name: "name", - description: "description", - }, - lv: { - type: "group_content", - name: "name", - description: "description", - }, - mn: { - type: "group_content", - name: "name", - description: "description", - }, - nb: { - type: "group_content", - name: "name", - description: "description", - }, - nl: { - type: "group_content", - name: "name", - description: "description", - }, - pl: { - type: "group_content", - name: "name", - description: "description", - }, - pt: { - type: "group_content", - name: "name", - description: "description", - }, - ro: { - type: "group_content", - name: "name", - description: "description", - }, - ru: { - type: "group_content", - name: "name", - description: "description", - }, - sl: { - type: "group_content", - name: "name", - description: "description", - }, - sr: { - type: "group_content", - name: "name", - description: "description", - }, - sv: { - type: "group_content", - name: "name", - description: "description", - }, - tr: { - type: "group_content", - name: "name", - description: "description", - }, - vi: { - type: "group_content", - name: "name", - description: "description", - }, - "pt-BR": { - type: "group_content", - name: "name", - description: "description", - }, - "zh-CN": { - type: "group_content", - name: "name", - description: "description", - }, - "zh-TW": { - type: "group_content", - name: "name", - description: "description", - }, - }, - parent_id: "parent_id", - help_center_id: 1, - }, - { - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - created_at: 1, - updated_at: 1, - url: "url", - icon: "icon", - order: 1, - default_locale: "default_locale", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "name", - description: "description", - }, - bg: { - type: "group_content", - name: "name", - description: "description", - }, - bs: { - type: "group_content", - name: "name", - description: "description", - }, - ca: { - type: "group_content", - name: "name", - description: "description", - }, - cs: { - type: "group_content", - name: "name", - description: "description", - }, - da: { - type: "group_content", - name: "name", - description: "description", - }, - de: { - type: "group_content", - name: "name", - description: "description", - }, - el: { - type: "group_content", - name: "name", - description: "description", - }, - en: { - type: "group_content", - name: "name", - description: "description", - }, - es: { - type: "group_content", - name: "name", - description: "description", - }, - et: { - type: "group_content", - name: "name", - description: "description", - }, - fi: { - type: "group_content", - name: "name", - description: "description", - }, - fr: { - type: "group_content", - name: "name", - description: "description", - }, - he: { - type: "group_content", - name: "name", - description: "description", - }, - hr: { - type: "group_content", - name: "name", - description: "description", - }, - hu: { - type: "group_content", - name: "name", - description: "description", - }, - id: { - type: "group_content", - name: "name", - description: "description", - }, - it: { - type: "group_content", - name: "name", - description: "description", - }, - ja: { - type: "group_content", - name: "name", - description: "description", - }, - ko: { - type: "group_content", - name: "name", - description: "description", - }, - lt: { - type: "group_content", - name: "name", - description: "description", - }, - lv: { - type: "group_content", - name: "name", - description: "description", - }, - mn: { - type: "group_content", - name: "name", - description: "description", - }, - nb: { - type: "group_content", - name: "name", - description: "description", - }, - nl: { - type: "group_content", - name: "name", - description: "description", - }, - pl: { - type: "group_content", - name: "name", - description: "description", - }, - pt: { - type: "group_content", - name: "name", - description: "description", - }, - ro: { - type: "group_content", - name: "name", - description: "description", - }, - ru: { - type: "group_content", - name: "name", - description: "description", - }, - sl: { - type: "group_content", - name: "name", - description: "description", - }, - sr: { - type: "group_content", - name: "name", - description: "description", - }, - sv: { - type: "group_content", - name: "name", - description: "description", - }, - tr: { - type: "group_content", - name: "name", - description: "description", - }, - vi: { - type: "group_content", - name: "name", - description: "description", - }, - "pt-BR": { - type: "group_content", - name: "name", - description: "description", - }, - "zh-CN": { - type: "group_content", - name: "name", - description: "description", - }, - "zh-TW": { - type: "group_content", - name: "name", - description: "description", - }, - }, - parent_id: "parent_id", - help_center_id: 1, - }, - ], - }; - const page = await client.helpCenters.collections.list(); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint({ once: false }) - .get("/help_center/collections") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Thanks for everything" }; - const rawResponseBody = { - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 81, - }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.create({ - name: "Thanks for everything", - }); - expect(response).toEqual({ - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 81, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "collection 51", description: "Missing required parameter" }; - const rawResponseBody = { - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 81, - }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.create({ - name: "collection 51", - description: "Missing required parameter", - }); - expect(response).toEqual({ - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 81, - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.create({ - name: "name", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.create({ - name: "name", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "170", - workspace_id: "this_is_an_id106_that_should_be_at_least_", - name: "English collection title", - description: "english collection description", - created_at: 1734537315, - updated_at: 1734537315, - url: "http://help-center.test/myapp-106/collection-22", - icon: "bookmark", - order: 22, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 84, - }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.find({ - collection_id: 1, - }); - expect(response).toEqual({ - id: "170", - workspace_id: "this_is_an_id106_that_should_be_at_least_", - name: "English collection title", - description: "english collection description", - created_at: 1734537315, - updated_at: 1734537315, - url: "http://help-center.test/myapp-106/collection-22", - icon: "bookmark", - order: 22, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 84, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.find({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.find({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Update collection name" }; - const rawResponseBody = { - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 87, - }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.update({ - collection_id: 1, - name: "Update collection name", - }); - expect(response).toEqual({ - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 87, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Update collection name" }; - const rawResponseBody = { - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 87, - }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.update({ - collection_id: 1, - name: "Update collection name", - }); - expect(response).toEqual({ - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 87, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.update({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.update({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "182", object: "collection", deleted: true }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.helpCenters.collections.delete({ - collection_id: 1, - }); - expect(response).toEqual({ - id: "182", - object: "collection", - deleted: true, - }); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.delete({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.helpCenters.collections.delete({ - collection_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/internalArticles.test.ts b/tests/wire/internalArticles.test.ts deleted file mode 100644 index 3ef231a2..00000000 --- a/tests/wire/internalArticles.test.ts +++ /dev/null @@ -1,655 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("InternalArticlesClient", () => { - test("listInternalArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "internal_article", - id: "39", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }; - server.mockEndpoint().get("/internal_articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.internalArticles.listInternalArticles(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "internal_article", - id: "39", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }); - }); - - test("listInternalArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/internal_articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.internalArticles.listInternalArticles(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("createInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252, - }; - const rawResponseBody = { - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .post("/internal_articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252, - }); - expect(response).toEqual({ - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("createInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - body: "Body of the Internal Article", - author_id: 1295, - owner_id: 1295, - }; - const rawResponseBody = { - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .post("/internal_articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Internal Article", - author_id: 1295, - owner_id: 1295, - }); - expect(response).toEqual({ - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("createInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/internal_articles") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("createInternalArticle (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/internal_articles") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("retrieveInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "internal_article", - id: "45", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.retrieveInternalArticle({ - internal_article_id: 1, - }); - expect(response).toEqual({ - type: "internal_article", - id: "45", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("retrieveInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.retrieveInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("retrieveInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.retrieveInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("updateInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.updateInternalArticle({ - internal_article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("updateInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.updateInternalArticle({ - internal_article_id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("updateInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.updateInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("updateInternalArticle (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.updateInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("deleteInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "51", object: "internal_article", deleted: true }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.deleteInternalArticle({ - internal_article_id: 1, - }); - expect(response).toEqual({ - id: "51", - object: "internal_article", - deleted: true, - }); - }); - - test("deleteInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.deleteInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.deleteInternalArticle({ - internal_article_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("searchInternalArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - total_count: 1, - data: { - internal_articles: [ - { - id: "55", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - }; - server - .mockEndpoint() - .get("/internal_articles/search") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.internalArticles.searchInternalArticles({ - folder_id: "folder_id", - }); - expect(response).toEqual({ - type: "list", - total_count: 1, - data: { - internal_articles: [ - { - id: "55", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - }); - }); - - test("searchInternalArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/internal_articles/search") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.internalArticles.searchInternalArticles(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/ipAllowlist.test.ts b/tests/wire/ipAllowlist.test.ts deleted file mode 100644 index de84803f..00000000 --- a/tests/wire/ipAllowlist.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("IpAllowlistClient", () => { - test("getIpAllowlist (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "ip_allowlist", enabled: true, ip_allowlist: ["192.168.1.0/24", "10.0.0.1"] }; - server.mockEndpoint().get("/ip_allowlist").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.ipAllowlist.getIpAllowlist(); - expect(response).toEqual({ - type: "ip_allowlist", - enabled: true, - ip_allowlist: ["192.168.1.0/24", "10.0.0.1"], - }); - }); - - test("getIpAllowlist (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ip_allowlist").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.ipAllowlist.getIpAllowlist(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("updateIpAllowlist (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { enabled: true, ip_allowlist: ["192.168.1.0/24", "10.0.0.1"] }; - const rawResponseBody = { type: "ip_allowlist", enabled: true, ip_allowlist: ["192.168.1.0/24", "10.0.0.1"] }; - server - .mockEndpoint() - .put("/ip_allowlist") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ipAllowlist.updateIpAllowlist({ - enabled: true, - ip_allowlist: ["192.168.1.0/24", "10.0.0.1"], - }); - expect(response).toEqual({ - type: "ip_allowlist", - enabled: true, - ip_allowlist: ["192.168.1.0/24", "10.0.0.1"], - }); - }); - - test("updateIpAllowlist (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ip_allowlist") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ipAllowlist.updateIpAllowlist({}); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("updateIpAllowlist (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/ip_allowlist") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ipAllowlist.updateIpAllowlist({}); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/jobs.test.ts b/tests/wire/jobs.test.ts deleted file mode 100644 index ed487a93..00000000 --- a/tests/wire/jobs.test.ts +++ /dev/null @@ -1,97 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("JobsClient", () => { - test("status (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "job", - id: "2", - url: "https://api.intercom.io/jobs/status/20", - status: "success", - resource_type: "ticket", - resource_id: "20", - resource_url: "https://api.intercom.io/tickets/20", - }; - server - .mockEndpoint() - .get("/jobs/status/job_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.jobs.status({ - job_id: "job_id", - }); - expect(response).toEqual({ - type: "job", - id: "2", - url: "https://api.intercom.io/jobs/status/20", - status: "success", - resource_type: "ticket", - resource_id: "20", - resource_url: "https://api.intercom.io/tickets/20", - }); - }); - - test("status (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/jobs/status/job_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.jobs.status({ - job_id: "job_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("status (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/jobs/status/job_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.jobs.status({ - job_id: "job_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/messages.test.ts b/tests/wire/messages.test.ts deleted file mode 100644 index 4c5270c9..00000000 --- a/tests/wire/messages.test.ts +++ /dev/null @@ -1,618 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("MessagesClient", () => { - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "inapp", - subject: "heyy", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "6762f23b1bb69f9f2193bc1a" }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "inapp", - subject: "heyy", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "6762f23b1bb69f9f2193bc1a", - }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "hey there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "hey there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "heyy", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "6762f23d1bb69f9f2193bc1c" }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "heyy", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "6762f23d1bb69f9f2193bc1c", - }, - created_at: 1590000000, - create_conversation_without_contact_reply: true, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("create (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "user_message", - id: "403918397", - created_at: 1734537783, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "614", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "user_message", - id: "403918397", - created_at: 1734537783, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "614", - }); - }); - - test("create (9)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { type: "admin", id: 394051 }, - to: { type: "user", id: "536e564f316c83104c000020" }, - }; - const rawResponseBody = { - type: "admin_message", - id: "19", - created_at: 1734537786, - subject: "heyy", - body: "heyy", - message_type: "inapp", - conversation_id: "64619700005570", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.messages.create({ - message_type: "email", - subject: "Thanks for everything", - body: "Hello there", - template: "plain", - from: { - type: "admin", - id: 394051, - }, - to: { - type: "user", - id: "536e564f316c83104c000020", - }, - }); - expect(response).toEqual({ - type: "admin_message", - id: "19", - created_at: 1734537786, - subject: "heyy", - body: "heyy", - message_type: "inapp", - conversation_id: "64619700005570", - }); - }); - - test("create (10)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/messages").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.messages.create(undefined); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (11)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/messages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.messages.create(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (12)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/messages").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.messages.create(undefined); - }).rejects.toThrow(Intercom.ForbiddenError); - }); - - test("create (13)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/messages").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.messages.create(undefined); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/news/feeds.test.ts b/tests/wire/news/feeds.test.ts deleted file mode 100644 index 67e2d4e5..00000000 --- a/tests/wire/news/feeds.test.ts +++ /dev/null @@ -1,257 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("FeedsClient", () => { - test("listItems (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 0, - }, - total_count: 0, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }; - server - .mockEndpoint() - .get("/news/newsfeeds/123/items") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.feeds.listItems({ - newsfeed_id: "123", - }); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 0, - }, - total_count: 0, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }); - }); - - test("listItems (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/news/newsfeeds/newsfeed_id/items") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.feeds.listItems({ - newsfeed_id: "newsfeed_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { type: "newsfeed", id: "12312", name: "My Newsfeed", created_at: 1674917488, updated_at: 1674917488 }, - { type: "newsfeed", id: "12312", name: "My Newsfeed", created_at: 1674917488, updated_at: 1674917488 }, - ], - }; - server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.news.feeds.list(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - id: "12312", - type: "newsfeed", - name: "My Newsfeed", - created_at: 1674917488, - updated_at: 1674917488, - }, - { - id: "12312", - type: "newsfeed", - name: "My Newsfeed", - created_at: 1674917488, - updated_at: 1674917488, - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.news.feeds.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "72", - type: "newsfeed", - name: "Visitor Feed", - created_at: 1734537815, - updated_at: 1734537815, - }; - server - .mockEndpoint() - .get("/news/newsfeeds/123") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.feeds.find({ - newsfeed_id: "123", - }); - expect(response).toEqual({ - id: "72", - type: "newsfeed", - name: "Visitor Feed", - created_at: 1734537815, - updated_at: 1734537815, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/news/newsfeeds/newsfeed_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.feeds.find({ - newsfeed_id: "newsfeed_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/news/items.test.ts b/tests/wire/news/items.test.ts deleted file mode 100644 index e95bc74e..00000000 --- a/tests/wire/news/items.test.ts +++ /dev/null @@ -1,620 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ItemsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }; - server.mockEndpoint().get("/news/news_items").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.news.items.list(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/news_items").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.news.items.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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: ["😆", "😅"], - newsfeed_assignments: [{ newsfeed_id: 53, published_at: 1664638214 }], - }; - const rawResponseBody = { - type: "news-item", - id: "33", - workspace_id: "this_is_an_id534_that_should_be_at_least_", - title: "Halloween is here!", - body: "

New costumes in store for this spooky season

", - sender_id: 991267834, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 53, published_at: 1664638214 }], - labels: ["New", "Product", "Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😆", "😅"], - deliver_silently: true, - created_at: 1734537797, - updated_at: 1734537797, - }; - server - .mockEndpoint() - .post("/news/news_items") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.items.create({ - 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, - }, - ], - }); - expect(response).toEqual({ - type: "news-item", - id: "33", - workspace_id: "this_is_an_id534_that_should_be_at_least_", - title: "Halloween is here!", - body: "

New costumes in store for this spooky season

", - sender_id: 991267834, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 53, - published_at: 1664638214, - }, - ], - labels: ["New", "Product", "Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], - deliver_silently: true, - created_at: 1734537797, - updated_at: 1734537797, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/news/news_items") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.items.create({ - title: "title", - sender_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "news-item", - id: "34", - workspace_id: "this_is_an_id538_that_should_be_at_least_", - title: "We have news", - body: "

Hello there,

", - sender_id: 991267837, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 55, published_at: 1734537800 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍", "👍", "👍", "👍"], - deliver_silently: false, - created_at: 1734537800, - updated_at: 1734537800, - }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.news.items.find({ - news_item_id: 1, - }); - expect(response).toEqual({ - type: "news-item", - id: "34", - workspace_id: "this_is_an_id538_that_should_be_at_least_", - title: "We have news", - body: "

Hello there,

", - sender_id: 991267837, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 55, - published_at: 1734537800, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D", "\uD83D\uDC4D", "\uD83D\uDC4D", "\uD83D\uDC4D"], - deliver_silently: false, - created_at: 1734537800, - updated_at: 1734537800, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.news.items.find({ - news_item_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.news.items.find({ - news_item_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - reactions: ["😝", "😂"], - }; - const rawResponseBody = { - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😝", "😂"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.items.update({ - news_item_id: 1, - body: { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - }, - }); - expect(response).toEqual({ - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267848, - reactions: ["😝", "😂"], - }; - const rawResponseBody = { - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😝", "😂"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.items.update({ - news_item_id: 1, - body: { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267848, - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - }, - }); - expect(response).toEqual({ - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.items.update({ - news_item_id: 1, - body: { - title: "title", - sender_id: 1, - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.items.update({ - news_item_id: 1, - body: { - title: "title", - sender_id: 1, - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "40", object: "news-item", deleted: true }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.news.items.delete({ - news_item_id: 1, - }); - expect(response).toEqual({ - id: "40", - object: "news-item", - deleted: true, - }); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.items.delete({ - news_item_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.news.items.delete({ - news_item_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/notes.test.ts b/tests/wire/notes.test.ts deleted file mode 100644 index 6082e324..00000000 --- a/tests/wire/notes.test.ts +++ /dev/null @@ -1,527 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("NotesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "type", - data: [ - { - type: "type", - id: "id", - created_at: 1, - contact: { type: "type", id: "id" }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: { image_url: "image_url" }, - team_priority_level: { primary_team_ids: [1, 1], secondary_team_ids: [1, 1] }, - }, - body: "body", - }, - { - type: "type", - id: "id", - created_at: 1, - contact: { type: "type", id: "id" }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: { image_url: "image_url" }, - team_priority_level: { primary_team_ids: [1, 1], secondary_team_ids: [1, 1] }, - }, - body: "body", - }, - ], - total_count: 1, - }; - server - .mockEndpoint({ once: false }) - .get("/contacts/contact_id/notes") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "type", - data: [ - { - type: "type", - id: "id", - created_at: 1, - contact: { - type: "type", - id: "id", - }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: { - image_url: "image_url", - }, - team_priority_level: { - primary_team_ids: [1, 1], - secondary_team_ids: [1, 1], - }, - }, - body: "body", - }, - { - type: "type", - id: "id", - created_at: 1, - contact: { - type: "type", - id: "id", - }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: { - image_url: "image_url", - }, - team_priority_level: { - primary_team_ids: [1, 1], - secondary_team_ids: [1, 1], - }, - }, - body: "body", - }, - ], - total_count: 1, - }; - const page = await client.notes.list({ - contact_id: "contact_id", - }); - - expect(expected.data).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.data).toEqual(nextPage.data); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/contacts/contact_id/notes") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.notes.list({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/123/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.notes.create({ - contact_id: "123", - body: "Hello", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/123/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.notes.create({ - contact_id: "123", - body: "Hello", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/123/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.notes.create({ - contact_id: "123", - body: "Hello", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "body" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.notes.create({ - contact_id: "contact_id", - body: "body", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "note", - id: "34", - created_at: 1733846617, - contact: { type: "contact", id: "6762f2591bb69f9f2193bc1f" }, - author: { - type: "admin", - id: "991267864", - name: "Ciaran346 Lee", - email: "admin346@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { image_url: "https://example.org/128Wash.jpg" }, - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

This is a note.

", - }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.notes.find({ - note_id: 1, - }); - expect(response).toEqual({ - type: "note", - id: "34", - created_at: 1733846617, - contact: { - type: "contact", - id: "6762f2591bb69f9f2193bc1f", - }, - author: { - type: "admin", - id: "991267864", - name: "Ciaran346 Lee", - email: "admin346@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - image_url: "https://example.org/128Wash.jpg", - }, - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

This is a note.

", - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.notes.find({ - note_id: 1, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.notes.find({ - note_id: 1, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/phoneCallRedirects.test.ts b/tests/wire/phoneCallRedirects.test.ts deleted file mode 100644 index a81d3a78..00000000 --- a/tests/wire/phoneCallRedirects.test.ts +++ /dev/null @@ -1,216 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("PhoneCallRedirectsClient", () => { - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - phone: "+353832345678", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { type: "phone_call_redirect", phone: "+1 1234567890" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.phoneCallRedirects.create({ - phone: "+353832345678", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "phone_call_redirect", - phone: "+1 1234567890", - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - phone: "+353832345678", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { type: "phone_call_redirect", phone: "+1 1234567890" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.phoneCallRedirects.create({ - phone: "+353832345678", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "phone_call_redirect", - phone: "+1 1234567890", - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - phone: "+353832345678", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { type: "phone_call_redirect", phone: "+1 1234567890" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.phoneCallRedirects.create({ - phone: "+353832345678", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "phone_call_redirect", - phone: "+1 1234567890", - }); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - phone: "+40241100100", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { type: "phone_call_redirect", phone: "+1 1234567890" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.phoneCallRedirects.create({ - phone: "+40241100100", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "phone_call_redirect", - phone: "+1 1234567890", - }); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.phoneCallRedirects.create(undefined); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.phoneCallRedirects.create(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.phoneCallRedirects.create(undefined); - }).rejects.toThrow(Intercom.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/segments.test.ts b/tests/wire/segments.test.ts deleted file mode 100644 index 0639194d..00000000 --- a/tests/wire/segments.test.ts +++ /dev/null @@ -1,174 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("SegmentsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "segment.list", - segments: [ - { - type: "segment", - id: "6762f25c1bb69f9f2193bc22", - name: "John segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - { - type: "segment", - id: "6762f25c1bb69f9f2193bc23", - name: "Jane segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - ], - pages: { key: "value" }, - }; - server.mockEndpoint().get("/segments").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.segments.list({ - include_count: true, - }); - expect(response).toEqual({ - type: "segment.list", - segments: [ - { - type: "segment", - id: "6762f25c1bb69f9f2193bc22", - name: "John segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - { - type: "segment", - id: "6762f25c1bb69f9f2193bc23", - name: "Jane segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - ], - pages: { - key: "value", - }, - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/segments").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.segments.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "segment", - id: "6762f25f1bb69f9f2193bc26", - name: "John segment", - created_at: 1734537823, - updated_at: 1734537823, - person_type: "user", - count: 3, - }; - server.mockEndpoint().get("/segments/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.segments.find({ - segment_id: "123", - }); - expect(response).toEqual({ - type: "segment", - id: "6762f25f1bb69f9f2193bc26", - name: "John segment", - created_at: 1734537823, - updated_at: 1734537823, - person_type: "user", - count: 3, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/segments/segment_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.segments.find({ - segment_id: "segment_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/segments/segment_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.segments.find({ - segment_id: "segment_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/subscriptionTypes.test.ts b/tests/wire/subscriptionTypes.test.ts deleted file mode 100644 index dc2a94b1..00000000 --- a/tests/wire/subscriptionTypes.test.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("SubscriptionTypesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "subscription", - id: "135", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_out", - content_types: ["email"], - }, - ], - }; - server - .mockEndpoint() - .get("/subscription_types") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.subscriptionTypes.list(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "subscription", - id: "135", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_out", - content_types: ["email"], - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/subscription_types") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.subscriptionTypes.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/tags.test.ts b/tests/wire/tags.test.ts deleted file mode 100644 index b31a212b..00000000 --- a/tests/wire/tags.test.ts +++ /dev/null @@ -1,1371 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("TagsClient", () => { - test("tagContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "123" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagContact (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/contact_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("tagContact (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("untagContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "tag", - id: "84", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/contacts/63a07ddf05a32042dffac965/tags/7522907") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagContact({ - contact_id: "63a07ddf05a32042dffac965", - tag_id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "84", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/tags/tag_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagContact({ - contact_id: "contact_id", - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("untagContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/tags/tag_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagContact({ - contact_id: "contact_id", - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("tagConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/conversations/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/conversations/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("tagConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("untagConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagConversation({ - conversation_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagConversation({ - conversation_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagConversation({ - conversation_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/tags/tag_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagConversation({ - conversation_id: "conversation_id", - tag_id: "tag_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("untagConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/tags/tag_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagConversation({ - conversation_id: "conversation_id", - tag_id: "tag_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "tag", - id: "102", - name: "Manual tag 1", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }; - server.mockEndpoint().get("/tags").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.tags.list(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "tag", - id: "102", - name: "Manual tag 1", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tags").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.create({ - name: "test", - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Independent" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.create({ - name: "Independent", - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", companies: [{ company_id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.create({ - name: "test", - companies: [ - { - company_id: "123", - }, - ], - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", users: [{ id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.create({ - name: "test", - users: [ - { - id: "123", - }, - ], - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.create({ - name: "name", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("create (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.create({ - name: "name", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.create({ - name: "name", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server.mockEndpoint().get("/tags/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.tags.find({ - tag_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tags/tag_id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.find({ - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/tags/tag_id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.find({ - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().delete("/tags/123").respondWith().statusCode(200).build(); - - const response = await client.tags.delete({ - tag_id: "123", - }); - expect(response).toEqual(undefined); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tags/tag_id").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.delete({ - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/tags/tag_id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.delete({ - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("delete (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tags/tag_id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tags.delete({ - tag_id: "tag_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("tagTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tickets/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tickets/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.tagTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("tagTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/ticket_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("tagTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/ticket_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.tagTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("untagTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagTicket({ - ticket_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagTicket({ - ticket_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tags.untagTicket({ - ticket_id: "64619700005694", - tag_id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("untagTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/tickets/ticket_id/tags/tag_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagTicket({ - ticket_id: "ticket_id", - tag_id: "tag_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("untagTicket (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/tickets/ticket_id/tags/tag_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tags.untagTicket({ - ticket_id: "ticket_id", - tag_id: "tag_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/teams.test.ts b/tests/wire/teams.test.ts deleted file mode 100644 index d9706101..00000000 --- a/tests/wire/teams.test.ts +++ /dev/null @@ -1,144 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("TeamsClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "team.list", - teams: [ - { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, - assignment_limit: 10, - distribution_method: "round_robin", - }, - ], - }; - server.mockEndpoint().get("/teams").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.teams.list(); - expect(response).toEqual({ - type: "team.list", - teams: [ - { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, - assignment_limit: 10, - distribution_method: "round_robin", - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.teams.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "team", - id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, - assignment_limit: 10, - distribution_method: "round_robin", - }; - server.mockEndpoint().get("/teams/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.teams.find({ - team_id: "123", - }); - expect(response).toEqual({ - type: "team", - id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, - assignment_limit: 10, - distribution_method: "round_robin", - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams/team_id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.teams.find({ - team_id: "team_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/teams/team_id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.teams.find({ - team_id: "team_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); -}); diff --git a/tests/wire/ticketStates.test.ts b/tests/wire/ticketStates.test.ts deleted file mode 100644 index a510ca68..00000000 --- a/tests/wire/ticketStates.test.ts +++ /dev/null @@ -1,504 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("TicketStatesClient", () => { - test("listTicketStates (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "ticket_state", - id: "8269", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8270", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8271", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8272", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8273", - category: "submitted", - internal_label: "Admin label 1", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8274", - category: "submitted", - internal_label: "Admin label 2", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - ], - }; - server.mockEndpoint().get("/ticket_states").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.ticketStates.listTicketStates(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "ticket_state", - id: "8269", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8270", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8271", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8272", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8273", - category: "submitted", - internal_label: "Admin label 1", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8274", - category: "submitted", - internal_label: "Admin label 2", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - ], - }); - }); - - test("listTicketStates (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ticket_states").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.ticketStates.listTicketStates(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/ticketTypes.test.ts b/tests/wire/ticketTypes.test.ts deleted file mode 100644 index f1ec5429..00000000 --- a/tests/wire/ticketTypes.test.ts +++ /dev/null @@ -1,689 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("TicketTypesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "ticket_type", - id: "67", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id648_that_should_be_at_least_", - ticket_type_attributes: { type: "list" }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8321", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8322", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8323", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8324", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537866, - updated_at: 1734537866, - }, - ], - }; - server.mockEndpoint().get("/ticket_types").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.ticketTypes.list(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "ticket_type", - id: "67", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id648_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8321", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8322", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8323", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8324", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537866, - updated_at: 1734537866, - }, - ], - }); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ticket_types").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.ticketTypes.list(); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - name: "Customer Issue", - description: "Customer Report Template", - category: "Customer", - icon: "🎟️", - }; - const rawResponseBody = { - type: "ticket_type", - id: "70", - category: "Customer", - name: "Customer Issue", - description: "Customer Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id652_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { key: "value" }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8337", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8338", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8339", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8340", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537869, - updated_at: 1734537869, - }; - server - .mockEndpoint() - .post("/ticket_types") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ticketTypes.create({ - name: "Customer Issue", - description: "Customer Report Template", - category: "Customer", - icon: "\uD83C\uDF9F\uFE0F", - }); - expect(response).toEqual({ - type: "ticket_type", - id: "70", - category: "Customer", - name: "Customer Issue", - description: "Customer Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id652_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { - key: "value", - }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8337", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8338", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8339", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8340", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537869, - updated_at: 1734537869, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/ticket_types").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.ticketTypes.create(undefined); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("get (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "ticket_type", - id: "72", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id656_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { key: "value" }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8353", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8354", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8355", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8356", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537870, - updated_at: 1734537870, - }; - server - .mockEndpoint() - .get("/ticket_types/ticket_type_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ticketTypes.get({ - ticket_type_id: "ticket_type_id", - }); - expect(response).toEqual({ - type: "ticket_type", - id: "72", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id656_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { - key: "value", - }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8353", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8354", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8355", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8356", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537870, - updated_at: 1734537870, - }); - }); - - test("get (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ticket_types/ticket_type_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ticketTypes.get({ - ticket_type_id: "ticket_type_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Bug Report 2" }; - const rawResponseBody = { - type: "ticket_type", - id: "74", - category: "Customer", - name: "Bug Report 2", - description: "Bug Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id660_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { key: "value" }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8369", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8370", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8371", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8372", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537873, - updated_at: 1734537874, - }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ticketTypes.update({ - ticket_type_id: "ticket_type_id", - name: "Bug Report 2", - }); - expect(response).toEqual({ - type: "ticket_type", - id: "74", - category: "Customer", - name: "Bug Report 2", - description: "Bug Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id660_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - input_options: { - key: "value", - }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8369", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8370", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8371", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8372", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537873, - updated_at: 1734537874, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ticketTypes.update({ - ticket_type_id: "ticket_type_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/ticketTypes/attributes.test.ts b/tests/wire/ticketTypes/attributes.test.ts deleted file mode 100644 index 0bd0e735..00000000 --- a/tests/wire/ticketTypes/attributes.test.ts +++ /dev/null @@ -1,200 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("AttributesClient", () => { - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false, - }; - const rawResponseBody = { - type: "ticket_type_attribute", - id: "157", - workspace_id: "this_is_an_id640_that_should_be_at_least_", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - input_options: { multiline: false }, - order: 2, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: true, - visible_to_contacts: true, - default: false, - ticket_type_id: 63, - archived: false, - created_at: 1734537862, - updated_at: 1734537862, - }; - server - .mockEndpoint() - .post("/ticket_types/ticket_type_id/attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ticketTypes.attributes.create({ - ticket_type_id: "ticket_type_id", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false, - }); - expect(response).toEqual({ - type: "ticket_type_attribute", - id: "157", - workspace_id: "this_is_an_id640_that_should_be_at_least_", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - input_options: { - multiline: false, - }, - order: 2, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: true, - visible_to_contacts: true, - default: false, - ticket_type_id: 63, - archived: false, - created_at: 1734537862, - updated_at: 1734537862, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name", description: "description", data_type: "string" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ticket_types/ticket_type_id/attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ticketTypes.attributes.create({ - ticket_type_id: "ticket_type_id", - name: "name", - description: "description", - data_type: "string", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { description: "New Attribute Description" }; - const rawResponseBody = { - type: "ticket_type_attribute", - id: "162", - workspace_id: "this_is_an_id644_that_should_be_at_least_", - name: "name", - description: "New Attribute Description", - data_type: "string", - input_options: { key: "value" }, - order: 0, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: false, - ticket_type_id: 65, - archived: false, - created_at: 1734537864, - updated_at: 1734537864, - }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id/attributes/attribute_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.ticketTypes.attributes.update({ - ticket_type_id: "ticket_type_id", - attribute_id: "attribute_id", - description: "New Attribute Description", - }); - expect(response).toEqual({ - type: "ticket_type_attribute", - id: "162", - workspace_id: "this_is_an_id644_that_should_be_at_least_", - name: "name", - description: "New Attribute Description", - data_type: "string", - input_options: { - key: "value", - }, - order: 0, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: false, - ticket_type_id: 65, - archived: false, - created_at: 1734537864, - updated_at: 1734537864, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id/attributes/attribute_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.ticketTypes.attributes.update({ - ticket_type_id: "ticket_type_id", - attribute_id: "attribute_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tests/wire/tickets.test.ts b/tests/wire/tickets.test.ts deleted file mode 100644 index 928f3523..00000000 --- a/tests/wire/tickets.test.ts +++ /dev/null @@ -1,3690 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("TicketsClient", () => { - test("reply (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_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", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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" }, - ], - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_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", - }, - ], - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2a41bb69f9f2193bc4c", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2a41bb69f9f2193bc4c", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }; - const rawResponseBody = { - type: "ticket_part", - id: "158", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537890, - updated_at: 1734537890, - author: { type: "admin", id: "991267948", name: "Ciaran423 Lee", email: "admin423@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.reply({ - ticket_id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "158", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537890, - updated_at: 1734537890, - author: { - type: "admin", - id: "991267948", - name: "Ciaran423 Lee", - email: "admin423@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("reply (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/ticket_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.reply({ - ticket_id: "ticket_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("reply (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/ticket_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.reply({ - ticket_id: "ticket_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("reply (9)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/ticket_id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.reply({ - ticket_id: "ticket_id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "1234", contacts: [{ id: "6762f2d81bb69f9f2193bc54" }] }; - const rawResponseBody = { - type: "ticket", - id: "626", - ticket_id: "33", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8481", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "88", - category: "Back-office", - name: "my-ticket-type-23", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id688_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537943, - updated_at: 1734537943, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f2d81bb69f9f2193bc54", external_id: "70" }], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537944, - updated_at: 1734537946, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "175", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537945, - updated_at: 1734537945, - author: { - type: "bot", - id: "991267999", - name: "Fin", - email: "operator+this_is_an_id688_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }; - server - .mockEndpoint() - .post("/tickets") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.create({ - ticket_type_id: "1234", - contacts: [ - { - id: "6762f2d81bb69f9f2193bc54", - }, - ], - }); - expect(response).toEqual({ - type: "ticket", - id: "626", - ticket_id: "33", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8481", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "88", - category: "Back-office", - name: "my-ticket-type-23", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id688_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537943, - updated_at: 1734537943, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2d81bb69f9f2193bc54", - external_id: "70", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537944, - updated_at: 1734537946, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "175", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537945, - updated_at: 1734537945, - author: { - type: "bot", - id: "991267999", - name: "Fin", - email: "operator+this_is_an_id688_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.create({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("enqueueCreateTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "1234", contacts: [{ id: "6762f2d81bb69f9f2193bc54" }] }; - const rawResponseBody = { - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", - }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.enqueueCreateTicket({ - ticket_type_id: "1234", - contacts: [ - { - id: "6762f2d81bb69f9f2193bc54", - }, - ], - }); - expect(response).toEqual({ - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", - }); - }); - - test("enqueueCreateTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("enqueueCreateTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("get (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { _default_title_: "attribute_value", _default_description_: { key: "value" } }, - ticket_state: { - type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "95", - category: "Back-office", - name: "my-ticket-type-30", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id702_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537973, - updated_at: 1734537973, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, - author: { type: "admin", id: "991268047", name: "Ciaran509 Lee", email: "admin509@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }; - server.mockEndpoint().get("/tickets/ticket_id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.tickets.get({ - ticket_id: "ticket_id", - }); - expect(response).toEqual({ - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { - _default_title_: "attribute_value", - _default_description_: { - key: "value", - }, - }, - ticket_state: { - type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "95", - category: "Back-office", - name: "my-ticket-type-30", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id702_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537973, - updated_at: 1734537973, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, - author: { - type: "admin", - id: "991268047", - name: "Ciaran509 Lee", - email: "admin509@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }); - }); - - test("get (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tickets/ticket_id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.tickets.get({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.update({ - ticket_id: "ticket_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", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.update({ - ticket_id: "ticket_id", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.update({ - ticket_id: "ticket_id", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_state_id: "123" }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.update({ - ticket_id: "ticket_id", - ticket_state_id: "123", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("update (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.update({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.BadRequestError); - }); - - test("update (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.update({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/tickets/ticket_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.update({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("deleteTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "632", object: "ticket", deleted: true }; - server - .mockEndpoint() - .delete("/tickets/ticket_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.tickets.deleteTicket({ - ticket_id: "ticket_id", - }); - expect(response).toEqual({ - id: "632", - object: "ticket", - deleted: true, - }); - }); - - test("deleteTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/tickets/ticket_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.deleteTicket({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("deleteTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/tickets/ticket_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.tickets.deleteTicket({ - ticket_id: "ticket_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("search", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "ticket.list", - tickets: [ - { - type: "ticket", - id: "633", - ticket_id: "40", - category: "Back-office", - ticket_attributes: { _default_title_: "attribute_value" }, - ticket_state: { - type: "ticket_state", - id: "8577", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "100", - category: "Back-office", - name: "my-ticket-type-35", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id712_that_should_be_at_least_", - ticket_type_attributes: { type: "list" }, - archived: false, - created_at: 1734537989, - updated_at: 1734537989, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f3061bb69f9f2193bc5b", - external_id: "9b913927-c084-4391-b1db-098341b5ffe3", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537990, - updated_at: 1734537992, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "188", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537991, - updated_at: 1734537991, - author: { - type: "admin", - id: "991268079", - name: "Ciaran539 Lee", - email: "admin539@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 1, - }, - }; - server - .mockEndpoint({ once: false }) - .post("/tickets/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const expected = { - type: "ticket.list", - tickets: [ - { - type: "ticket", - id: "633", - ticket_id: "40", - category: "Back-office", - ticket_attributes: { - _default_title_: "attribute_value", - }, - ticket_state: { - type: "ticket_state", - id: "8577", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "100", - category: "Back-office", - name: "my-ticket-type-35", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id712_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - }, - archived: false, - created_at: 1734537989, - updated_at: 1734537989, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f3061bb69f9f2193bc5b", - external_id: "9b913927-c084-4391-b1db-098341b5ffe3", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537990, - updated_at: 1734537992, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "188", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537991, - updated_at: 1734537991, - author: { - type: "admin", - id: "991268079", - name: "Ciaran539 Lee", - email: "admin539@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 1, - }, - }; - const page = await client.tickets.search({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - - expect(expected.tickets).toEqual(page.data); - expect(page.hasNextPage()).toBe(true); - const nextPage = await page.getNextPage(); - expect(expected.tickets).toEqual(nextPage.data); - }); -}); diff --git a/tests/wire/unstable/admins.test.ts b/tests/wire/unstable/admins.test.ts deleted file mode 100644 index 15a2ae87..00000000 --- a/tests/wire/unstable/admins.test.ts +++ /dev/null @@ -1,644 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("AdminsClient", () => { - test("identifyAdmin", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }; - server.mockEndpoint().get("/me").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.identifyAdmin(); - expect(response).toEqual({ - type: "admin", - id: "991267459", - name: "Ciaran1 Lee", - email: "admin1@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - has_inbox_seat: true, - team_ids: [814865], - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/assets/default-avatars/admins/128.png", - }, - email_verified: true, - app: { - type: "app", - id_code: "this_is_an_id1_that_should_be_at_least_40", - name: "MyApp 1", - region: "US", - timezone: "America/Los_Angeles", - created_at: 1734537243, - identity_verification: false, - }, - }); - }); - - test("setAwayAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true, away_status_reason_id: 12345 }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - expect(response).toEqual({ - type: "admin", - id: "991267460", - name: "Ciaran2 Lee", - email: "admin2@email.com", - job_title: "Associate", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("setAwayAdmin (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("setAwayAdmin (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("setAwayAdmin (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { away_mode_enabled: true, away_mode_reassign: true }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/admins/1/away") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.setAwayAdmin({ - id: 1, - away_mode_enabled: true, - away_mode_reassign: true, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listActivityLogs (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { type: "admin", id: "991267464", email: "admin5@email.com", ip: "127.0.0.1" }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "😌 On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.admins.listActivityLogs({ - created_at_after: "1677253093", - created_at_before: "1677861493", - }); - expect(response).toEqual({ - type: "activity_log.list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - activity_logs: [ - { - id: "fca05814-4b72-4dce-ad4f-77a786a2c136", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "app_name_change", - activity_description: "Ciaran5 Lee changed your app name from before to after.", - }, - { - id: "f48c653b-0185-48ac-a276-23d11006bafb", - performed_by: { - type: "admin", - id: "991267464", - email: "admin5@email.com", - ip: "127.0.0.1", - }, - metadata: { - sign_in_method: "email_password", - external_id: "f3b87a2e09d514c6c2e79b9a", - away_mode: true, - away_status_reason: "\uD83D\uDE0C On a break", - reassign_conversations: false, - source: "admin update from web - Admin id: 93", - update_by: 93, - update_by_name: "Joe Example", - conversation_assignment_limit: 15, - ticket_assignment_limit: 20, - }, - created_at: 1734537253, - activity_type: "message_state_change", - activity_description: - "Ciaran5 Lee changed your Initial message title message from Initial message title to Eventual message title.", - }, - ], - }); - }); - - test("listActivityLogs (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/admins/activity_logs") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.admins.listActivityLogs({ - created_at_after: "created_at_after", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listAdmins (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - ], - }; - server.mockEndpoint().get("/admins").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.listAdmins(); - expect(response).toEqual({ - type: "admin.list", - admins: [ - { - type: "admin", - id: "991267466", - name: "Ciaran7 Lee", - email: "admin7@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - ], - }); - }); - - test("listAdmins (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.listAdmins(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveAdmin (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - expect(response).toEqual({ - type: "admin", - id: "991267468", - name: "Ciaran9 Lee", - email: "admin9@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }); - }); - - test("retrieveAdmin (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveAdmin (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/admins/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.admins.retrieveAdmin({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/aiContent.test.ts b/tests/wire/unstable/aiContent.test.ts deleted file mode 100644 index 4c0c8a22..00000000 --- a/tests/wire/unstable/aiContent.test.ts +++ /dev/null @@ -1,878 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("AiContentClient", () => { - test("listContentImportSources (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - total_count: 3, - data: [ - { - type: "content_import_source", - id: 33, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/1", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 34, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/2", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 35, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/3", - created_at: 1734537259, - updated_at: 1734537259, - }, - ], - }; - server - .mockEndpoint() - .get("/ai/content_import_sources") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.listContentImportSources(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - total_count: 3, - data: [ - { - type: "content_import_source", - id: 33, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/1", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 34, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/2", - created_at: 1734537259, - updated_at: 1734537259, - }, - { - type: "content_import_source", - id: 35, - last_synced_at: 1734537259, - sync_behavior: "automatic", - status: "active", - url: "https://support.example.com/us/3", - created_at: 1734537259, - updated_at: 1734537259, - }, - ], - }); - }); - - test("listContentImportSources (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/content_import_sources") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.listContentImportSources(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "https://www.example.com" }; - const rawResponseBody = { - type: "content_import_source", - id: 36, - last_synced_at: 1734537261, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537261, - updated_at: 1734537261, - }; - server - .mockEndpoint() - .post("/ai/content_import_sources") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.createContentImportSource({ - url: "https://www.example.com", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 36, - last_synced_at: 1734537261, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537261, - updated_at: 1734537261, - }); - }); - - test("createContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "url" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ai/content_import_sources") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.createContentImportSource({ - url: "url", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "content_import_source", - id: 38, - last_synced_at: 1734537265, - sync_behavior: "api", - status: "active", - url: "https://support.example.com/us/5", - created_at: 1734537265, - updated_at: 1734537265, - }; - server - .mockEndpoint() - .get("/ai/content_import_sources/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.getContentImportSource({ - id: "id", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 38, - last_synced_at: 1734537265, - sync_behavior: "api", - status: "active", - url: "https://support.example.com/us/5", - created_at: 1734537265, - updated_at: 1734537265, - }); - }); - - test("getContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/content_import_sources/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.getContentImportSource({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "https://www.example.com" }; - const rawResponseBody = { - type: "content_import_source", - id: 39, - last_synced_at: 1734537267, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537267, - updated_at: 1734537267, - }; - server - .mockEndpoint() - .put("/ai/content_import_sources/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.updateContentImportSource({ - id: "id", - sync_behavior: "api", - url: "https://www.example.com", - }); - expect(response).toEqual({ - type: "content_import_source", - id: 39, - last_synced_at: 1734537267, - sync_behavior: "api", - status: "active", - url: "https://www.example.com", - created_at: 1734537267, - updated_at: 1734537267, - }); - }); - - test("updateContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { sync_behavior: "api", url: "url" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ai/content_import_sources/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.updateContentImportSource({ - id: "id", - sync_behavior: "api", - url: "url", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteContentImportSource (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().delete("/ai/content_import_sources/id").respondWith().statusCode(200).build(); - - const response = await client.unstable.aiContent.deleteContentImportSource({ - id: "id", - }); - expect(response).toEqual(undefined); - }); - - test("deleteContentImportSource (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/ai/content_import_sources/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.deleteContentImportSource({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listExternalPages (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - total_count: 3, - data: [ - { - type: "external_page", - id: "19", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/3", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 42, - external_id: "3", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "18", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/2", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 41, - external_id: "2", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "17", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/1", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 40, - external_id: "1", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - ], - }; - server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.aiContent.listExternalPages(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - total_count: 3, - data: [ - { - type: "external_page", - id: "19", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/3", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 42, - external_id: "3", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "18", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/2", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 41, - external_id: "2", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - { - type: "external_page", - id: "17", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/1", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 40, - external_id: "1", - created_at: 1734537269, - updated_at: 1734537269, - last_ingested_at: 1734537269, - }, - ], - }); - }); - - test("listExternalPages (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ai/external_pages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.aiContent.listExternalPages(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Test", - html: "

Test

", - url: "https://www.example.com", - locale: "en", - source_id: 44, - external_id: "abc1234", - }; - const rawResponseBody = { - type: "external_page", - id: "21", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 44, - external_id: "abc1234", - created_at: 1734537273, - updated_at: 1734537274, - last_ingested_at: 1734537274, - }; - server - .mockEndpoint() - .post("/ai/external_pages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.createExternalPage({ - title: "Test", - html: "

Test

", - url: "https://www.example.com", - source_id: 44, - external_id: "abc1234", - }); - expect(response).toEqual({ - type: "external_page", - id: "21", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 44, - external_id: "abc1234", - created_at: 1734537273, - updated_at: 1734537274, - last_ingested_at: 1734537274, - }); - }); - - test("createExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", html: "html", locale: "en", source_id: 1, external_id: "external_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ai/external_pages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.createExternalPage({ - title: "title", - html: "html", - source_id: 1, - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "external_page", - id: "23", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/6", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 46, - external_id: "5", - created_at: 1734537278, - updated_at: 1734537278, - last_ingested_at: 1734537278, - }; - server - .mockEndpoint() - .get("/ai/external_pages/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.getExternalPage({ - id: "id", - }); - expect(response).toEqual({ - type: "external_page", - id: "23", - title: "My External Content", - html: "

Hello world

This is external content

", - url: "https://support.example.com/us/6", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 46, - external_id: "5", - created_at: 1734537278, - updated_at: 1734537278, - last_ingested_at: 1734537278, - }); - }); - - test("getExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/ai/external_pages/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.getExternalPage({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Test", - html: "

Test

", - url: "https://www.example.com", - locale: "en", - source_id: 47, - external_id: "5678", - }; - const rawResponseBody = { - type: "external_page", - id: "24", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 47, - external_id: "5678", - created_at: 1734537280, - updated_at: 1734537281, - last_ingested_at: 1734537281, - }; - server - .mockEndpoint() - .put("/ai/external_pages/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.updateExternalPage({ - id: "id", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - source_id: 47, - external_id: "5678", - }); - expect(response).toEqual({ - type: "external_page", - id: "24", - title: "Test", - html: "

Test

", - url: "https://www.example.com", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 47, - external_id: "5678", - created_at: 1734537280, - updated_at: 1734537281, - last_ingested_at: 1734537281, - }); - }); - - test("updateExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", html: "html", url: "url", locale: "en", source_id: 1 }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ai/external_pages/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.updateExternalPage({ - id: "id", - title: "title", - html: "html", - url: "url", - source_id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteExternalPage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "external_page", - id: "22", - title: "My External Content", - html: "", - url: "https://support.example.com/us/5", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 45, - external_id: "4", - created_at: 1734537276, - updated_at: 1734537276, - last_ingested_at: 1734537276, - }; - server - .mockEndpoint() - .delete("/ai/external_pages/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.aiContent.deleteExternalPage({ - id: "id", - }); - expect(response).toEqual({ - type: "external_page", - id: "22", - title: "My External Content", - html: "", - url: "https://support.example.com/us/5", - ai_agent_availability: true, - ai_copilot_availability: true, - fin_availability: true, - locale: "en", - source_id: 45, - external_id: "4", - created_at: 1734537276, - updated_at: 1734537276, - last_ingested_at: 1734537276, - }); - }); - - test("deleteExternalPage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/ai/external_pages/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.aiContent.deleteExternalPage({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/articles.test.ts b/tests/wire/unstable/articles.test.ts deleted file mode 100644 index 20562566..00000000 --- a/tests/wire/unstable/articles.test.ts +++ /dev/null @@ -1,2141 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ArticlesClient", () => { - test("listArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "article", - id: "39", - workspace_id: "this_is_an_id64_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267492, - state: "published", - created_at: 1734537283, - updated_at: 1734537283, - url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", - parent_id: 143, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - }; - server.mockEndpoint().get("/articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.listArticles(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "article", - id: "39", - workspace_id: "this_is_an_id64_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267492, - state: "published", - created_at: 1734537283, - updated_at: 1734537283, - url: "http://help-center.test/myapp-64/en/articles/39-this-is-the-article-title", - parent_id: 143, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - }); - }); - - test("listArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.listArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - statistics: { - type: "article_statistics", - views: 1, - conversions: 1, - reactions: 1, - happy_reaction_percentage: 1.1, - neutral_reaction_percentage: 1.1, - sad_reaction_percentage: 1.1, - }, - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.articles.createArticle({ - key: "value", - }); - expect(response).toEqual({ - statistics: { - type: "article_statistics", - views: 1, - conversions: 1, - reactions: 1, - happy_reaction_percentage: 1.1, - neutral_reaction_percentage: 1.1, - sad_reaction_percentage: 1.1, - }, - type: "article", - id: "id", - workspace_id: "workspace_id", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - parent_id: 1, - parent_ids: [1, 1], - parent_type: "parent_type", - default_locale: "default_locale", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bg: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - bs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ca: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - cs: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - da: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - de: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - el: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - en: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - es: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - et: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - fr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - he: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - hu: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - id: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - it: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ja: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ko: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - lv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - mn: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nb: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - nl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - pt: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ro: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - ru: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sl: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - sv: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - tr: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - vi: { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "pt-BR": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-CN": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - "zh-TW": { - type: "article_content", - title: "title", - description: "description", - body: "body", - author_id: 1, - state: "published", - created_at: 1, - updated_at: 1, - url: "url", - }, - }, - }); - }); - - test("createArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.articles.createArticle({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.articles.createArticle({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.retrieveArticle({ - id: 1, - }); - expect(response).toEqual({ - type: "article", - id: "45", - workspace_id: "this_is_an_id74_that_should_be_at_least_4", - title: "This is the article title", - description: "", - body: "", - author_id: 991267502, - state: "published", - created_at: 1734537292, - updated_at: 1734537292, - url: "http://help-center.test/myapp-74/en/articles/45-this-is-the-article-title", - parent_id: 148, - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - translated_content: { - type: "article_translated_content", - ar: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bg: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - bs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ca: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - cs: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - da: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - de: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - el: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - en: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - es: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - et: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - fr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - he: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - hu: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - id: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - it: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ja: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ko: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - lv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - mn: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nb: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - nl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - pt: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ro: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - ru: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sl: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - sv: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - tr: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - vi: { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "pt-BR": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-CN": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - "zh-TW": { - type: "article_content", - title: "How to create a new article", - description: "This article will show you how to create a new article.", - body: "This is the body of the article.", - author_id: 1, - state: "published", - created_at: 1663597223, - updated_at: 1663597260, - url: "http://intercom.test/help/en/articles/3-default-language", - }, - }, - statistics: { - type: "article_statistics", - views: 0, - conversions: 0, - reactions: 0, - happy_reaction_percentage: 0, - neutral_reaction_percentage: 0, - sad_reaction_percentage: 0, - }, - }); - }); - - test("retrieveArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.retrieveArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.retrieveArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "51", object: "article", deleted: true }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.deleteArticle({ - id: 1, - }); - expect(response).toEqual({ - id: "51", - object: "article", - deleted: true, - }); - }); - - test("deleteArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.deleteArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/articles/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.deleteArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("searchArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [{ article_id: "123" }], - }, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.articles.searchArticles({ - phrase: "Getting started", - state: "published", - help_center_id: 1, - highlight: true, - }); - expect(response).toEqual({ - type: "list", - total_count: 1, - data: { - articles: [ - { - type: "article", - id: "55", - workspace_id: "this_is_an_id92_that_should_be_at_least_4", - title: "Title 1", - description: "", - body: "", - author_id: 991267521, - state: "draft", - created_at: 1734537306, - updated_at: 1734537306, - url: "http://intercom.test/help/en/articles/3-default-language", - parent_ids: [18, 19], - parent_type: "collection", - default_locale: "en", - }, - ], - highlights: [ - { - article_id: "123", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - }); - }); - - test("searchArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/articles/search").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.articles.searchArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/awayStatusReasons.test.ts b/tests/wire/unstable/awayStatusReasons.test.ts deleted file mode 100644 index f0416817..00000000 --- a/tests/wire/unstable/awayStatusReasons.test.ts +++ /dev/null @@ -1,74 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("AwayStatusReasonsClient", () => { - test("listAwayStatusReasons (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = [ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "☕", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]; - server - .mockEndpoint() - .get("/away_status_reasons") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.awayStatusReasons.listAwayStatusReasons(); - expect(response).toEqual([ - { - type: "away_status_reason", - id: "id", - label: "On a break", - emoji: "\u2615", - order: 1, - deleted: false, - created_at: 1734537243, - updated_at: 1734537243, - }, - ]); - }); - - test("listAwayStatusReasons (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/away_status_reasons") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.awayStatusReasons.listAwayStatusReasons(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/brands.test.ts b/tests/wire/unstable/brands.test.ts deleted file mode 100644 index 5dfe7df0..00000000 --- a/tests/wire/unstable/brands.test.ts +++ /dev/null @@ -1,162 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("BrandsClient", () => { - test("listBrands (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "brand", - id: "tlkp1d91", - name: "Default Brand", - is_default: true, - created_at: 1673778600, - updated_at: 1711031100, - help_center_id: "11", - default_address_settings_id: "13", - }, - { - type: "brand", - id: "3", - name: "Premium Brand", - is_default: false, - created_at: 1686387300, - updated_at: 1709229600, - help_center_id: "10", - default_address_settings_id: "15", - }, - ], - }; - server.mockEndpoint().get("/brands").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.brands.listBrands(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "brand", - id: "tlkp1d91", - name: "Default Brand", - is_default: true, - created_at: 1673778600, - updated_at: 1711031100, - help_center_id: "11", - default_address_settings_id: "13", - }, - { - type: "brand", - id: "3", - name: "Premium Brand", - is_default: false, - created_at: 1686387300, - updated_at: 1709229600, - help_center_id: "10", - default_address_settings_id: "15", - }, - ], - }); - }); - - test("listBrands (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/brands").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.brands.listBrands(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveBrand (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "brand", - id: "15", - name: "Premium Brand", - is_default: false, - created_at: 1686387300, - updated_at: 1709229600, - help_center_id: "20", - default_address_settings_id: "15", - }; - server.mockEndpoint().get("/brands/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.brands.retrieveBrand({ - id: "id", - }); - expect(response).toEqual({ - type: "brand", - id: "15", - name: "Premium Brand", - is_default: false, - created_at: 1686387300, - updated_at: 1709229600, - help_center_id: "20", - default_address_settings_id: "15", - }); - }); - - test("retrieveBrand (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/brands/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.brands.retrieveBrand({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveBrand (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/brands/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.brands.retrieveBrand({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/calls.test.ts b/tests/wire/unstable/calls.test.ts deleted file mode 100644 index 4840a470..00000000 --- a/tests/wire/unstable/calls.test.ts +++ /dev/null @@ -1,758 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CallsClient", () => { - test("listCalls (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 0, - }, - }; - server.mockEndpoint().get("/calls").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.calls.listCalls({ - page: 1, - per_page: 1, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 0, - }, - }); - }); - - test("listCalls (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/calls").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.calls.listCalls(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("showCall (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: 1734537437, - answered_at: 1734537440, - ended_at: 1734537530, - created_at: 1734537437, - updated_at: 1734537531, - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "answered", - phone: "+15551234567", - fin_recording_url: "https://api.intercom.io/calls/124/recording", - fin_transcription_url: "https://api.intercom.io/calls/124/transcript", - }; - server.mockEndpoint().get("/calls/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.calls.showCall({ - id: "id", - }); - expect(response).toEqual({ - type: "call", - id: "123", - conversation_id: "456", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: 1734537437, - answered_at: 1734537440, - ended_at: 1734537530, - created_at: 1734537437, - updated_at: 1734537531, - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "answered", - phone: "+15551234567", - fin_recording_url: "https://api.intercom.io/calls/124/recording", - fin_transcription_url: "https://api.intercom.io/calls/124/transcript", - }); - }); - - test("showCall (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/calls/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.calls.showCall({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("showCall (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/calls/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.calls.showCall({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("showCallRecording (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().get("/calls/id/recording").respondWith().statusCode(200).build(); - - const response = await client.unstable.calls.showCallRecording({ - id: "id", - }); - expect(response).toEqual(undefined); - }); - - test("showCallRecording (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/calls/id/recording") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.showCallRecording({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("showCallRecording (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/calls/id/recording") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.showCallRecording({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listCallsWithTranscripts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["64619700005694", "64619700005695"] }; - const rawResponseBody = { - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "64619700005694", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - transcript: [{ key: "value" }], - transcript_status: "completed", - }, - ], - }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.calls.listCallsWithTranscripts({ - conversation_ids: ["64619700005694", "64619700005695"], - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "call", - id: "123", - conversation_id: "64619700005694", - admin_id: "789", - contact_id: "6762f0dd1bb69f9f2193bb83", - state: "completed", - initiated_at: "2024-01-15T09:30:00Z", - answered_at: "2024-01-15T09:30:00Z", - ended_at: "2024-01-15T09:30:00Z", - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - recording_url: "https://api.intercom.io/calls/123/recording", - transcription_url: "https://api.intercom.io/calls/123/transcript", - call_type: "phone", - direction: "outbound", - ended_reason: "completed", - phone: "+15551234567", - fin_recording_url: "fin_recording_url", - fin_transcription_url: "fin_transcription_url", - transcript: [ - { - key: "value", - }, - ], - transcript_status: "completed", - }, - ], - }); - }); - - test("listCallsWithTranscripts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["conversation_ids", "conversation_ids"] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.listCallsWithTranscripts({ - conversation_ids: ["conversation_ids", "conversation_ids"], - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("listCallsWithTranscripts (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { conversation_ids: ["conversation_ids", "conversation_ids"] }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/calls/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.listCallsWithTranscripts({ - conversation_ids: ["conversation_ids", "conversation_ids"], - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("registerFinVoiceCall (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { phone_number: "+1234567890", call_id: "call-123-abc" }; - const rawResponseBody = { - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [{ key: "value" }], - call_summary: "Customer called about billing issue...", - intent: [{ key: "value" }], - }; - server - .mockEndpoint() - .post("/fin_voice/register") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.calls.registerFinVoiceCall({ - phone_number: "+1234567890", - call_id: "call-123-abc", - }); - expect(response).toEqual({ - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [ - { - key: "value", - }, - ], - call_summary: "Customer called about billing issue...", - intent: [ - { - key: "value", - }, - ], - }); - }); - - test("registerFinVoiceCall (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/fin_voice/register") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.registerFinVoiceCall(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("registerFinVoiceCall (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/fin_voice/register") - .respondWith() - .statusCode(409) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.registerFinVoiceCall(undefined); - }).rejects.toThrow(Intercom.unstable.ConflictError); - }); - - test("collectFinVoiceCallById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [{ key: "value" }], - call_summary: "Customer called about billing issue...", - intent: [{ key: "value" }], - }; - server - .mockEndpoint() - .get("/fin_voice/collect/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.calls.collectFinVoiceCallById({ - id: 1, - }); - expect(response).toEqual({ - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [ - { - key: "value", - }, - ], - call_summary: "Customer called about billing issue...", - intent: [ - { - key: "value", - }, - ], - }); - }); - - test("collectFinVoiceCallById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/fin_voice/collect/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallById({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("collectFinVoiceCallByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [{ key: "value" }], - call_summary: "Customer called about billing issue...", - intent: [{ key: "value" }], - }; - server - .mockEndpoint() - .get("/fin_voice/external_id/external_id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.calls.collectFinVoiceCallByExternalId({ - external_id: "external_id", - }); - expect(response).toEqual({ - id: 12345, - app_id: 12345, - user_phone_number: "+1234567890", - status: "registered", - intercom_call_id: "1234", - external_call_id: "call-123-abc", - intercom_conversation_id: "5678", - call_transcript: [ - { - key: "value", - }, - ], - call_summary: "Customer called about billing issue...", - intent: [ - { - key: "value", - }, - ], - }); - }); - - test("collectFinVoiceCallByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/fin_voice/external_id/external_id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByExternalId({ - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("collectFinVoiceCallByPhoneNumber (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "error.list", - request_id: "f93ecfa8-d08a-4325-8694-89aeb89c8f85", - errors: [{ code: "unauthorized", message: "Access Token Invalid", field: "email" }], - }; - server - .mockEndpoint() - .get("/fin_voice/phone_number/phone_number") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - phone_number: "phone_number", - }); - expect(response).toEqual({ - type: "error.list", - request_id: "f93ecfa8-d08a-4325-8694-89aeb89c8f85", - errors: [ - { - code: "unauthorized", - message: "Access Token Invalid", - field: "email", - }, - ], - }); - }); - - test("collectFinVoiceCallByPhoneNumber (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/fin_voice/phone_number/phone_number") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - phone_number: "phone_number", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("collectFinVoiceCallByPhoneNumber (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/fin_voice/phone_number/phone_number") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.calls.collectFinVoiceCallByPhoneNumber({ - phone_number: "phone_number", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/companies.test.ts b/tests/wire/unstable/companies.test.ts deleted file mode 100644 index 646e1411..00000000 --- a/tests/wire/unstable/companies.test.ts +++ /dev/null @@ -1,2011 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CompaniesClient", () => { - test("retrieveCompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 15, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f07a1bb69f9f2193baea", - name: "IntercomQATest1", - app_id: "this_is_an_id153_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537338, - created_at: 1734537338, - updated_at: 1734537338, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { type: "note.list" }, - }, - ], - }; - server.mockEndpoint().get("/companies").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.companies.retrieveCompany({ - name: "my company", - company_id: "12345", - tag_id: "678910", - segment_id: "98765", - page: 1, - per_page: 1, - }); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 15, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f07a1bb69f9f2193baea", - name: "IntercomQATest1", - app_id: "this_is_an_id153_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537338, - created_at: 1734537338, - updated_at: 1734537338, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - }, - }, - ], - }); - }); - - test("retrieveCompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/companies").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.retrieveCompany(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveCompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/companies").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.retrieveCompany(); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("createOrUpdateCompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - type: "company", - id: "id", - name: "name", - app_id: "app_id", - plan: { type: "type", id: "id", name: "name" }, - company_id: "company_id", - remote_created_at: 1, - created_at: 1, - updated_at: 1, - last_request_at: 1, - size: 1, - website: "website", - industry: "industry", - monthly_spend: 1, - session_count: 1, - user_count: 1, - custom_attributes: { custom_attributes: "custom_attributes" }, - tags: { type: "tag.list", tags: [{ key: "value" }, { key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - type: "segment", - id: "id", - name: "name", - created_at: 1, - updated_at: 1, - person_type: "contact", - count: 1, - }, - { - type: "segment", - id: "id", - name: "name", - created_at: 1, - updated_at: 1, - person_type: "contact", - count: 1, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "type", - id: "id", - created_at: 1, - company: { type: "type", id: "id" }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: "avatar", - team_priority_level: {}, - }, - body: "body", - }, - { - type: "type", - id: "id", - created_at: 1, - company: { type: "type", id: "id" }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: "avatar", - team_priority_level: {}, - }, - body: "body", - }, - ], - }, - }; - server - .mockEndpoint() - .post("/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.createOrUpdateCompany({ - key: "value", - }); - expect(response).toEqual({ - type: "company", - id: "id", - name: "name", - app_id: "app_id", - plan: { - type: "type", - id: "id", - name: "name", - }, - company_id: "company_id", - remote_created_at: 1, - created_at: 1, - updated_at: 1, - last_request_at: 1, - size: 1, - website: "website", - industry: "industry", - monthly_spend: 1, - session_count: 1, - user_count: 1, - custom_attributes: { - custom_attributes: "custom_attributes", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - type: "segment", - id: "id", - name: "name", - created_at: 1, - updated_at: 1, - person_type: "contact", - count: 1, - }, - { - type: "segment", - id: "id", - name: "name", - created_at: 1, - updated_at: 1, - person_type: "contact", - count: 1, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "type", - id: "id", - created_at: 1, - company: { - type: "type", - id: "id", - }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: "avatar", - team_priority_level: {}, - }, - body: "body", - }, - { - type: "type", - id: "id", - created_at: 1, - company: { - type: "type", - id: "id", - }, - author: { - type: "type", - id: "id", - name: "name", - email: "email", - job_title: "job_title", - away_mode_enabled: true, - away_mode_reassign: true, - away_status_reason_id: 1, - has_inbox_seat: true, - team_ids: [1, 1], - avatar: "avatar", - team_priority_level: {}, - }, - body: "body", - }, - ], - }, - }); - }); - - test("createOrUpdateCompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.createOrUpdateCompany({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createOrUpdateCompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.createOrUpdateCompany({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("RetrieveACompanyById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f07f1bb69f9f2193baf5", - name: "company1", - app_id: "this_is_an_id159_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537343, - created_at: 1734537343, - updated_at: 1734537343, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.retrieveACompanyById({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "company", - id: "6762f07f1bb69f9f2193baf5", - name: "company1", - app_id: "this_is_an_id159_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537343, - created_at: 1734537343, - updated_at: 1734537343, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("RetrieveACompanyById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.retrieveACompanyById({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("RetrieveACompanyById (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.retrieveACompanyById({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("UpdateCompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .put("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.updateCompany({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "company", - id: "6762f0841bb69f9f2193baff", - name: "company2", - app_id: "this_is_an_id165_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537348, - created_at: 1734537348, - updated_at: 1734537348, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("UpdateCompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().put("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.updateCompany({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("UpdateCompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().put("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.updateCompany({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteCompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "6762f0881bb69f9f2193bb09", object: "company", deleted: true }; - server - .mockEndpoint() - .delete("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.deleteCompany({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - id: "6762f0881bb69f9f2193bb09", - object: "company", - deleted: true, - }); - }); - - test("deleteCompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/companies/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.deleteCompany({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteCompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/companies/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.deleteCompany({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("ListAttachedContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 50, - total_pages: 0, - }, - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/contacts") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.listAttachedContacts({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 50, - total_pages: 0, - }, - }); - }); - - test("ListAttachedContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/companies/id/contacts") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.listAttachedContacts({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ListAttachedContacts (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/id/contacts") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.listAttachedContacts({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("ListAttachedSegmentsForCompanies (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "segment", - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - person_type: "contact", - count: 3, - }, - ], - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/segments") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.listAttachedSegmentsForCompanies({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "segment", - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - person_type: "contact", - count: 3, - }, - ], - }); - }); - - test("ListAttachedSegmentsForCompanies (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/companies/id/segments") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.listAttachedSegmentsForCompanies({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ListAttachedSegmentsForCompanies (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/id/segments") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.listAttachedSegmentsForCompanies({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listAllCompanies (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 15, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f0941bb69f9f2193bb25", - name: "IntercomQATest1", - app_id: "this_is_an_id189_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537364, - created_at: 1734537364, - updated_at: 1734537364, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { type: "note.list" }, - }, - ], - }; - server.mockEndpoint().post("/companies/list").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.companies.listAllCompanies({ - page: 1, - per_page: 1, - order: "desc", - }); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 15, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "company", - id: "6762f0941bb69f9f2193bb25", - name: "IntercomQATest1", - app_id: "this_is_an_id189_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537364, - created_at: 1734537364, - updated_at: 1734537364, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - }, - }, - ], - }); - }); - - test("listAllCompanies (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/companies/list").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.listAllCompanies(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("scrollOverAllCompanies (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "company", - id: "6762f0971bb69f9f2193bb2b", - name: "IntercomQATest1", - app_id: "this_is_an_id193_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537367, - created_at: 1734537367, - updated_at: 1734537367, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { key: "value" }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { type: "note.list" }, - }, - ], - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 2, - total_pages: 13, - }, - total_count: 100, - scroll_param: "69352cd2-ab5b-42ac-b004-a13d4e55e9b0", - }; - server.mockEndpoint().get("/companies/scroll").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.companies.scrollOverAllCompanies({ - scroll_param: "scroll_param", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "company", - id: "6762f0971bb69f9f2193bb2b", - name: "IntercomQATest1", - app_id: "this_is_an_id193_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "remote_companies_scroll_2", - remote_created_at: 1734537367, - created_at: 1734537367, - updated_at: 1734537367, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 4, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - }, - }, - ], - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 2, - total_pages: 13, - }, - total_count: 100, - scroll_param: "69352cd2-ab5b-42ac-b004-a13d4e55e9b0", - }); - }); - - test("scrollOverAllCompanies (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/companies/scroll").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.companies.scrollOverAllCompanies(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachContactToACompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "6762f09a1bb69f9f2193bb34" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "6762f09a1bb69f9f2193bb34", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("attachContactToACompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "58a430d35458202d41b1e65b" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "58a430d35458202d41b1e65b", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("attachContactToACompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "123" }; - const rawResponseBody = { - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "123", - }); - expect(response).toEqual({ - type: "company", - id: "6762f09a1bb69f9f2193bb34", - name: "company6", - app_id: "this_is_an_id197_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537370, - created_at: 1734537370, - updated_at: 1734537370, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 1, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("attachContactToACompany (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "company_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("attachContactToACompany (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "company_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachContactToACompany (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { company_id: "company_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/id/companies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.attachContactToACompany({ - id: "id", - company_id: "company_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachContactFromACompany (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "company", - id: "6762f0a01bb69f9f2193bb44", - name: "company8", - app_id: "this_is_an_id205_that_should_be_at_least_", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "1", - remote_created_at: 1734537376, - created_at: 1734537376, - updated_at: 1734537377, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { key: "value" }, - tags: { type: "tag.list", tags: [{ key: "value" }] }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [{ type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }], - }, - }; - server - .mockEndpoint() - .delete("/contacts/58a430d35458202d41b1e65b/companies/58a430d35458202d41b1e65b") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.companies.detachContactFromACompany({ - contact_id: "58a430d35458202d41b1e65b", - id: "58a430d35458202d41b1e65b", - }); - expect(response).toEqual({ - type: "company", - id: "6762f0a01bb69f9f2193bb44", - name: "company8", - app_id: "this_is_an_id205_that_should_be_at_least_", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "1", - remote_created_at: 1734537376, - created_at: 1734537376, - updated_at: 1734537377, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 0, - session_count: 0, - user_count: 0, - custom_attributes: { - key: "value", - }, - tags: { - type: "tag.list", - tags: [ - { - key: "value", - }, - ], - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }); - }); - - test("detachContactFromACompany (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/companies/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.detachContactFromACompany({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachContactFromACompany (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/companies/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.companies.detachContactFromACompany({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/contacts.test.ts b/tests/wire/unstable/contacts.test.ts deleted file mode 100644 index 4893898e..00000000 --- a/tests/wire/unstable/contacts.test.ts +++ /dev/null @@ -1,2297 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ContactsClient", () => { - test("listCompaniesForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - total_count: 1, - pages: { type: "pages", page: 1, next: "next", per_page: 50, total_pages: 1 }, - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/companies") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listCompaniesForAContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - companies: [ - { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: "next", - per_page: 50, - total_pages: 1, - }, - }); - }); - - test("listCompaniesForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/id/companies") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listCompaniesForAContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listCompaniesForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/id/companies") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listCompaniesForAContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listSegmentsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/segments") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "segment", - id: "6762f0b21bb69f9f2193bb65", - name: "segment", - created_at: 1734537394, - updated_at: 1734537394, - person_type: "user", - count: 3, - }, - ], - }); - }); - - test("listSegmentsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listSegmentsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/segments") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSegmentsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listSubscriptionsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/subscriptions") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "subscription", - id: "91", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_out", - content_types: ["email"], - }, - { - type: "subscription", - id: "93", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }, - ], - }); - }); - - test("listSubscriptionsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listSubscriptionsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/subscriptions") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listSubscriptionsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listTagsForAContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965/tags") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.listTagsForAContact({ - contact_id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "tag", - id: "80", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }); - }); - - test("listTagsForAContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listTagsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listTagsForAContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/contacts/contact_id/tags") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.listTagsForAContact({ - contact_id: "contact_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("ShowContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/63a07ddf05a32042dffac965") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.showContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d01bb69f9f2193bb7d", - external_id: "70", - workspace_id: "this_is_an_id283_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537424, - updated_at: 1734537424, - signed_up_at: 1734537424, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d01bb69f9f2193bb7d/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("ShowContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.showContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("UpdateContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io", name: "joe bloggs" }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.updateContact({ - id: "63a07ddf05a32042dffac965", - email: "joebloggs@intercom.io", - name: "joe bloggs", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("UpdateContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { custom_attributes: { order: ["21"] } }; - const rawResponseBody = { - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { order_number: "ORDER-12345", total_amount: 99.99 }, - type: "Order", - }, - ], - }, - }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .put("/contacts/63a07ddf05a32042dffac965") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.updateContact({ - id: "63a07ddf05a32042dffac965", - custom_attributes: { - order: ["21"], - }, - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0cd1bb69f9f2193bb7c", - external_id: "70", - workspace_id: "this_is_an_id279_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "joe bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537421, - updated_at: 1734537422, - signed_up_at: 1734537421, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { - order_number: "ORDER-12345", - total_amount: 99.99, - }, - type: "Order", - }, - ], - }, - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0cd1bb69f9f2193bb7c/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("UpdateContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/contacts/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.updateContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("DeleteContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", deleted: true }; - server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.contacts.deleteContact({ - id: "id", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - deleted: true, - }); - }); - - test("DeleteContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/contacts/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.deleteContact({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("MergeContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: "6762f0d51bb69f9f2193bb7f", into: "6762f0d51bb69f9f2193bb80" }; - const rawResponseBody = { - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.mergeContact({ - from: "6762f0d51bb69f9f2193bb7f", - into: "6762f0d51bb69f9f2193bb80", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0d51bb69f9f2193bb80", - external_id: "70", - workspace_id: "this_is_an_id291_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537429, - updated_at: 1734537430, - signed_up_at: 1734537429, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0d51bb69f9f2193bb80/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("MergeContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/merge") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.mergeContact(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("SearchContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 0, - }, - }; - server - .mockEndpoint() - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.searchContacts({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 0, - }, - }); - }); - - test("SearchContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { query: {} }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.searchContacts({ - query: {}, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ListContacts (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", total_count: 100, has_more: true }, - notes: { url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", total_count: 100, has_more: true }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 0, - }, - }; - server.mockEndpoint().get("/contacts").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.contacts.listContacts(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "ecahpwf5", - role: "user", - email: "joe@example.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: true, - marked_email_as_spam: true, - unsubscribed_from_emails: true, - created_at: 1571672154, - updated_at: 1571672154, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/tags", - total_count: 100, - has_more: true, - }, - notes: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - total_count: 100, - has_more: true, - }, - companies: { - url: "/contacts/5ba682d23d7cf92bef87bfd4/companies", - total_count: 100, - has_more: true, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - }, - ], - total_count: 0, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 0, - }, - }); - }); - - test("ListContacts (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/contacts").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.contacts.listContacts(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("CreateContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { email: "joebloggs@intercom.io" }; - const rawResponseBody = { - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.createContact({ - email: "joebloggs@intercom.io", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0dd1bb69f9f2193bb83", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id303_that_should_be_at_least_", - role: "user", - email: "joebloggs@intercom.io", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537437, - updated_at: 1734537437, - signed_up_at: 1571672154, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0dd1bb69f9f2193bb83/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("CreateContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.createContact({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ShowContactByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - enabled_push_messaging: true, - }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/cdd29344-5e0c-4ef0-ac56-f9ba2979bc27") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.showContactByExternalId({ - external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", - }); - expect(response).toEqual({ - type: "contact", - id: "6762f0df1bb69f9f2193bb84", - external_id: "70", - workspace_id: "this_is_an_id307_that_should_be_at_least_", - role: "user", - email: "joe@bloggs.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "Joe Bloggs", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734537439, - updated_at: 1734537439, - signed_up_at: 1734537439, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f0df1bb69f9f2193bb84/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - enabled_push_messaging: true, - }); - }); - - test("ShowContactByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/contacts/find_by_external_id/external_id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.contacts.showContactByExternalId({ - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("ArchiveContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/archive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.archiveContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: true, - }); - }); - - test("UnarchiveContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", archived: false }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/unarchive") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.unarchiveContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - archived: false, - }); - }); - - test("BlockContact", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70", blocked: true }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/block") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.contacts.blockContact({ - id: "63a07ddf05a32042dffac965", - }); - expect(response).toEqual({ - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - blocked: true, - }); - }); -}); diff --git a/tests/wire/unstable/conversations.test.ts b/tests/wire/unstable/conversations.test.ts deleted file mode 100644 index 88fb1544..00000000 --- a/tests/wire/unstable/conversations.test.ts +++ /dev/null @@ -1,13176 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ConversationsClient", () => { - test("listConversations (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "471", - title: "Conversation Title", - created_at: 1734537460, - updated_at: 1734537460, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], - }, - conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, - source: { - type: "conversation", - id: "403918320", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267628", - name: "Ciaran166 Lee", - email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f0f31bb69f9f2193bb8b", external_id: "70" }], - }, - teammates: { type: "admin.list" }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - }; - server.mockEndpoint().get("/conversations").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.conversations.listConversations({ - per_page: 1, - starting_after: "starting_after", - }); - expect(response).toEqual({ - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "471", - title: "Conversation Title", - created_at: 1734537460, - updated_at: 1734537460, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - }, - source: { - type: "conversation", - id: "403918320", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267628", - name: "Ciaran166 Lee", - email: "admin166@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f0f31bb69f9f2193bb8b", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - }); - }); - - test("listConversations (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.listConversations(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listConversations (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.listConversations(); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("createConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "user", id: "6762f11b1bb69f9f2193bba3" }, body: "Hello there" }; - const rawResponseBody = { - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.createConversation({ - from: { - type: "user", - id: "6762f11b1bb69f9f2193bba3", - }, - body: "Hello there", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }); - }); - - test("createConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "user", id: "123_doesnt_exist" }, body: "Hello there" }; - const rawResponseBody = { - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.createConversation({ - from: { - type: "user", - id: "123_doesnt_exist", - }, - body: "Hello there", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918330", - created_at: 1734537501, - subject: "Greetings", - body: "Hello there", - message_type: "inapp", - conversation_id: "499", - }); - }); - - test("createConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.createConversation({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.createConversation({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("createConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { from: { type: "lead", id: "blackcurrant............" }, body: "body" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.createConversation({ - from: { - type: "lead", - id: "blackcurrant............", - }, - body: "body", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("retrieveConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "conversation", - id: "503", - title: "Conversation Title", - created_at: 1734537511, - updated_at: 1734537511, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918334", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267645", - name: "Ciaran176 Lee", - email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1261bb69f9f2193bba7", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - assigned_to: { type: "contact", id: "1a2b3c" }, - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_started", - body: "

Okay!

", - created_at: 1740141842, - updated_at: 1740141842, - notified_at: 1740141842, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { action: { name: "Jira Create Issue" } }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1740141851, - updated_at: 1740141851, - notified_at: 1740141851, - author: { - type: "bot", - id: "278", - name: "Fin", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { attribute: { name: "jira_issue_key" }, value: { name: "PROJ-007" } }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_finished", - body: "

Okay!

", - created_at: 1740141857, - updated_at: 1740141857, - notified_at: 1740141857, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "closed", - tags: [{ type: "tag", id: "123456", name: "Test tag" }], - event_details: { action: { name: "Jira Create Issue", result: "success" } }, - app_package_code: "test-integration", - }, - ], - total_count: 4, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.conversations.retrieveConversation({ - id: 1, - display_as: "plaintext", - include_translations: true, - }); - expect(response).toEqual({ - type: "conversation", - id: "503", - title: "Conversation Title", - created_at: 1734537511, - updated_at: 1734537511, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918334", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267645", - name: "Ciaran176 Lee", - email: "admin176@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1261bb69f9f2193bba7", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - assigned_to: { - type: "contact", - id: "1a2b3c", - }, - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_started", - body: "

Okay!

", - created_at: 1740141842, - updated_at: 1740141842, - notified_at: 1740141842, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - action: { - name: "Jira Create Issue", - }, - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1740141851, - updated_at: 1740141851, - notified_at: 1740141851, - author: { - type: "bot", - id: "278", - name: "Fin", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "open", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - attribute: { - name: "jira_issue_key", - }, - value: { - name: "PROJ-007", - }, - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "3", - part_type: "custom_action_finished", - body: "

Okay!

", - created_at: 1740141857, - updated_at: 1740141857, - notified_at: 1740141857, - author: { - type: "admin", - id: "274", - name: "Jamie Oliver", - email: "jamie+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - state: "closed", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - }, - ], - event_details: { - action: { - name: "Jira Create Issue", - result: "success", - }, - }, - app_package_code: "test-integration", - }, - ], - total_count: 4, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("retrieveConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("retrieveConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/conversations/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.conversations.retrieveConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - read: true, - title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.updateConversation({ - id: 1, - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1301bb69f9f2193bbab", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("updateConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { custom_attributes: { order: {} } }; - const rawResponseBody = { - type: "conversation", - id: "508", - title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1341bb69f9f2193bbac", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }, - ], - }, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 0, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.updateConversation({ - id: 1, - display_as: "plaintext", - custom_attributes: { - order: {}, - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "508", - title: "Conversation Title", - created_at: 1734537525, - updated_at: 1734537525, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918339", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267659", - name: "Ciaran185 Lee", - email: "admin185@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1341bb69f9f2193bbac", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - order: { - type: "Order.list", - instances: [ - { - id: "21", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1671028894, - updated_at: 1671028894, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }, - ], - }, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 0, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("updateConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - read: true, - title: "new conversation title", - custom_attributes: { issue_type: "Billing", priority: "High" }, - }; - const rawResponseBody = { - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1301bb69f9f2193bbab", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { issue_type: "Billing", priority: "High" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.updateConversation({ - id: 1, - display_as: "plaintext", - read: true, - title: "new conversation title", - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "507", - title: "Conversation Title", - created_at: 1734537521, - updated_at: 1734537523, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918338", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267653", - name: "Ciaran180 Lee", - email: "admin180@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1301bb69f9f2193bbab", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - issue_type: "Billing", - priority: "High", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "129", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - { - type: "conversation_part", - id: "130", - part_type: "conversation_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537523, - updated_at: 1734537523, - notified_at: 1734537523, - author: { - type: "bot", - id: "991267654", - name: "Fin", - email: "operator+this_is_an_id354_that_should_be_at_least_@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("updateConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("updateConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/conversations/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.updateConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "512", object: "conversation", deleted: true }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.deleteConversation({ - id: 1, - }); - expect(response).toEqual({ - id: "512", - object: "conversation", - deleted: true, - }); - }); - - test("deleteConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.deleteConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/1") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.deleteConversation({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("searchConversations", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }], - }, - conversation_rating: { rating: 5, remark: "", created_at: 1671028894, updated_at: 1671028894 }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267691", - name: "Ciaran210 Lee", - email: "admin210@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f14a1bb69f9f2193bbb3", external_id: "70" }], - }, - teammates: { type: "admin.list" }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { total_count: 1 }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 1, - }, - }; - server - .mockEndpoint() - .post("/conversations/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.searchConversations({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - expect(response).toEqual({ - type: "conversation.list", - conversations: [ - { - type: "conversation", - id: "515", - title: "Conversation Title", - created_at: 1734537546, - updated_at: 1734537546, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - }, - source: { - type: "conversation", - id: "403918346", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267691", - name: "Ciaran210 Lee", - email: "admin210@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f14a1bb69f9f2193bbb3", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_title: "My AI Workflow", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - }, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 1, - }, - }); - }); - - test("replyConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.replyConversation({ - id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1571bb69f9f2193bbbb", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("replyConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "conversation", - id: "525", - title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918350", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f15b1bb69f9f2193bbbc", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "133", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "525", - title: "Conversation Title", - created_at: 1734537563, - updated_at: 1734537565, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918350", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f15b1bb69f9f2193bbbc", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "133", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537565, - updated_at: 1734537565, - notified_at: 1734537565, - author: { - type: "admin", - id: "991267696", - name: "Ciaran213 Lee", - email: "admin213@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("replyConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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" }, - ], - }; - const rawResponseBody = { - type: "conversation", - id: "526", - title: "Conversation Title", - created_at: 1734537567, - updated_at: 1734537568, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918351", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f15e1bb69f9f2193bbbd", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "134", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537568, - updated_at: 1734537568, - notified_at: 1734537568, - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - ], - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "526", - title: "Conversation Title", - created_at: 1734537567, - updated_at: 1734537568, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918351", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f15e1bb69f9f2193bbbd", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "134", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537568, - updated_at: 1734537568, - notified_at: 1734537568, - author: { - type: "admin", - id: "991267698", - name: "Ciaran214 Lee", - email: "admin214@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("replyConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "body", - reply_options: [{ text: "Yes", uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" }], - intercom_user_id: "6762f1621bb69f9f2193bbbe", - }; - const rawResponseBody = { - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1571bb69f9f2193bbbb", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "524", - title: "Conversation Title", - created_at: 1734537559, - updated_at: 1734537561, - waiting_since: 1734537561, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918349", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267694", - name: "Ciaran212 Lee", - email: "admin212@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1571bb69f9f2193bbbb", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537561, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "132", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537561, - updated_at: 1734537561, - notified_at: 1734537561, - author: { - type: "user", - id: "6762f1571bb69f9f2193bbbb", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("replyConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1661bb69f9f2193bbbf", - }; - const rawResponseBody = { - type: "conversation", - id: "527", - title: "Conversation Title", - created_at: 1734537571, - updated_at: 1734537572, - waiting_since: 1734537572, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918352", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267700", - name: "Ciaran215 Lee", - email: "admin215@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1621bb69f9f2193bbbe", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537572, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "135", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537572, - updated_at: 1734537572, - notified_at: 1734537572, - author: { - type: "user", - id: "6762f1621bb69f9f2193bbbe", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123%20or%20%22last%22/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.replyConversation({ - id: '123 or "last"', - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f1661bb69f9f2193bbbf", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "527", - title: "Conversation Title", - created_at: 1734537571, - updated_at: 1734537572, - waiting_since: 1734537572, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918352", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267700", - name: "Ciaran215 Lee", - email: "admin215@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1621bb69f9f2193bbbe", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537572, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "135", - part_type: "open", - body: "

Thanks again :)

", - created_at: 1734537572, - updated_at: 1734537572, - notified_at: 1734537572, - author: { - type: "user", - id: "6762f1621bb69f9f2193bbbe", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("replyConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.replyConversation({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("replyConversation (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.replyConversation({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("replyConversation (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.replyConversation({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("manageConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; - const rawResponseBody = { - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f16e1bb69f9f2193bbc2", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manageConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "snoozed", admin_id: "5017691", snoozed_until: 1673609604 }; - const rawResponseBody = { - type: "conversation", - id: "532", - title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, - open: true, - state: "snoozed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918357", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1711bb69f9f2193bbc3", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "snoozed", - admin_id: "5017691", - snoozed_until: 1673609604, - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "532", - title: "Conversation Title", - created_at: 1734537586, - updated_at: 1734537587, - waiting_since: 1663597260, - snoozed_until: 1734541187, - open: true, - state: "snoozed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918357", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1711bb69f9f2193bbc3", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "137", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537587, - updated_at: 1734537587, - notified_at: 1734537587, - author: { - type: "admin", - id: "991267710", - name: "Ciaran220 Lee", - email: "admin220@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manageConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "open", admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918358", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1781bb69f9f2193bbc8", external_id: "74" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "open", - admin_id: "5017690", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "537", - title: "", - created_at: 1734537587, - updated_at: 1734537601, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918358", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1781bb69f9f2193bbc8", - external_id: "74", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "139", - part_type: "open", - body: "

Okay!

", - created_at: 1734537601, - updated_at: 1734537601, - notified_at: 1734537601, - author: { - type: "admin", - id: "991267712", - name: "Ciaran221 Lee", - email: "admin221@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manageConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "assignment", type: "admin", admin_id: "12345", assignee_id: "4324241" }; - const rawResponseBody = { - type: "conversation", - id: "542", - title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918361", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1831bb69f9f2193bbcc", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", - body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { type: "admin", id: "991267715" }, - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "assignment", - type: "admin", - admin_id: "12345", - assignee_id: "4324241", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "542", - title: "Conversation Title", - created_at: 1734537603, - updated_at: 1734537605, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: false, - priority: "not_priority", - admin_assignee_id: 991267715, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918361", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1831bb69f9f2193bbcc", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "140", - part_type: "assign_and_reopen", - body: "

Okay!

", - created_at: 1734537605, - updated_at: 1734537605, - notified_at: 1734537605, - assigned_to: { - type: "admin", - id: "991267715", - }, - author: { - type: "admin", - id: "991267715", - name: "Ciaran223 Lee", - email: "admin223@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manageConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "12345" }; - const rawResponseBody = { - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f16e1bb69f9f2193bbc2", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.manageConversation({ - id: "123", - body: { - message_type: "close", - type: "admin", - admin_id: "12345", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "531", - title: "Conversation Title", - created_at: 1734537582, - updated_at: 1734537584, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: false, - state: "closed", - read: false, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918356", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f16e1bb69f9f2193bbc2", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "136", - part_type: "close", - body: "

Goodbye :)

", - created_at: 1734537584, - updated_at: 1734537584, - notified_at: 1734537584, - author: { - type: "admin", - id: "991267708", - name: "Ciaran219 Lee", - email: "admin219@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("manageConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("manageConversation (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("manageConversation (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { message_type: "close", type: "admin", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/id/parts") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.manageConversation({ - id: "id", - body: { - message_type: "close", - type: "admin", - admin_id: "admin_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("attachContactToConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19b1bb69f9f2193bbd4" } }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.attachContactToConversation({ - id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19b1bb69f9f2193bbd4", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("attachContactToConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "12345", customer: { intercom_user_id: "6762f19e1bb69f9f2193bbd5" } }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/123/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.attachContactToConversation({ - id: "123", - admin_id: "12345", - customer: { - intercom_user_id: "6762f19e1bb69f9f2193bbd5", - }, - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("attachContactToConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachContactToConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("attachContactToConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/id/customers") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.attachContactToConversation({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachContactFromConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactFromConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactFromConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactFromConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "5017690" }; - const rawResponseBody = { - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { type: "contact.list", contacts: [{ id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }] }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { - paid_subscriber: { type: "order.list", instances: [] }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 100, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .delete("/conversations/123/customers/123") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "123", - contact_id: "123", - admin_id: "5017690", - }); - expect(response).toEqual({ - type: "conversation", - id: "1295", - title: "Conversation Title", - created_at: 1663597223, - updated_at: 1663597260, - waiting_since: 1663597260, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "3", - delivered_as: "operator_initiated", - subject: "", - body: "

Hey there!

", - author: { - type: "admin", - id: "274", - name: "Operator", - email: "operator+abcd1234@intercom.io", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - paid_subscriber: { - type: "order.list", - instances: [], - }, - monthly_spend: "155.5", - team_mates: 9, - start_date_iso8601: "2023-03-04T09:46:14Z", - end_date_timestamp: 1677923174, - }, - first_contact_reply: { - created_at: 1663597223, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "3", - part_type: "comment", - body: "

Okay!

", - created_at: 1663597223, - updated_at: 1663597260, - notified_at: 1663597260, - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 100, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: true, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("detachContactFromConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachContactFromConversation (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("detachContactFromConversation (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachContactFromConversation (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/customers/contact_id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.detachContactFromConversation({ - conversation_id: "conversation_id", - contact_id: "contact_id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("listHandlingEvents (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - handling_events: [ - { - teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, - type: "paused", - timestamp: "2026-01-09T09:00:00Z", - reason: "Paused", - }, - { - teammate: { type: "admin", id: 123, name: "Jane Example", email: "jane@example.com" }, - type: "resumed", - timestamp: "2026-01-09T09:10:00Z", - reason: "Paused", - }, - ], - }; - server - .mockEndpoint() - .get("/conversations/123/handling_events") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.listHandlingEvents({ - id: "123", - }); - expect(response).toEqual({ - handling_events: [ - { - teammate: { - type: "admin", - id: 123, - name: "Jane Example", - email: "jane@example.com", - }, - type: "paused", - timestamp: "2026-01-09T09:00:00Z", - reason: "Paused", - }, - { - teammate: { - type: "admin", - id: 123, - name: "Jane Example", - email: "jane@example.com", - }, - type: "resumed", - timestamp: "2026-01-09T09:10:00Z", - reason: "Paused", - }, - ], - }); - }); - - test("listHandlingEvents (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/conversations/id/handling_events") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.listHandlingEvents({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listHandlingEvents (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/conversations/id/handling_events") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.listHandlingEvents({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("redactConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", - }; - const rawResponseBody = { - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "19894788788", - conversation_part_id: "19381789428", - }); - expect(response).toEqual({ - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1f81bb69f9f2193bc09", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("redactConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", - }; - const rawResponseBody = { - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { type: "plan", id: "269315", name: "Pro" }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { type: "tag.list" }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { type: "note", id: "17495962", created_at: 1674589321, body: "

Text for the note.

" }, - ], - }, - }, - tags: { type: "tag.list", tags: [{ type: "tag", id: "123456", name: "Test tag", applied_at: 1663597223 }] }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { type: "contact", id: "5ba682d23d7cf92bef87bfd4", external_id: "70" }, - teammate: { type: "contact", id: "1a2b3c" }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f1f81bb69f9f2193bc09", external_id: "70" }], - }, - teammates: { type: "admin.list", teammates: [{ type: "contact", id: "1a2b3c" }] }, - custom_attributes: { key: "value" }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { type: "conversation_sla_summary", sla_name: "", sla_status: "hit" }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - assigned_team_first_response_time_in_office_hours: [ - { team_id: 100, team_name: "Team One", response_time: 2310 }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000" }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "really_123_doesnt_exist", - conversation_part_id: "really_123_doesnt_exist", - }); - expect(response).toEqual({ - type: "conversation", - id: "608", - title: "Conversation Title", - created_at: 1734537721, - updated_at: 1734537724, - waiting_since: 1734537722, - snoozed_until: 1663597260, - open: true, - state: "open", - read: true, - priority: "not_priority", - admin_assignee_id: 0, - team_assignee_id: "5017691", - company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - company: { - type: "company", - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - plan: { - type: "plan", - id: "269315", - name: "Pro", - }, - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - tags: { - type: "tag.list", - }, - segments: { - type: "segment.list", - segments: [ - { - id: "56203d253cba154d39010062", - name: "Active", - created_at: 1394621988, - updated_at: 1394622004, - count: 3, - }, - ], - }, - notes: { - type: "note.list", - notes: [ - { - type: "note", - id: "17495962", - created_at: 1674589321, - body: "

Text for the note.

", - }, - ], - }, - }, - tags: { - type: "tag.list", - tags: [ - { - type: "tag", - id: "123456", - name: "Test tag", - applied_at: 1663597223, - }, - ], - }, - conversation_rating: { - rating: 5, - remark: "", - created_at: 1671028894, - updated_at: 1671028894, - contact: { - type: "contact", - id: "5ba682d23d7cf92bef87bfd4", - external_id: "70", - }, - teammate: { - type: "contact", - id: "1a2b3c", - }, - }, - source: { - type: "conversation", - id: "403918391", - delivered_as: "admin_initiated", - subject: "", - body: "

this is the message body

", - author: { - type: "admin", - id: "991267757", - name: "Ciaran247 Lee", - email: "admin247@email.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - url: "url", - redacted: false, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f1f81bb69f9f2193bc09", - external_id: "70", - }, - ], - }, - teammates: { - type: "admin.list", - teammates: [ - { - type: "contact", - id: "1a2b3c", - }, - ], - }, - custom_attributes: { - key: "value", - }, - first_contact_reply: { - created_at: 1734537722, - type: "conversation", - url: "https://developers.intercom.com/", - }, - sla_applied: { - type: "conversation_sla_summary", - sla_name: "", - sla_status: "hit", - }, - statistics: { - type: "conversation_statistics", - time_to_assignment: 2310, - time_to_admin_reply: 2310, - time_to_first_close: 2310, - time_to_last_close: 2310, - median_time_to_reply: 2310, - first_contact_reply_at: 1663597233, - first_assignment_at: 1663597233, - first_admin_reply_at: 1663597233, - first_close_at: 1663597233, - last_assignment_at: 1663597233, - last_assignment_admin_reply_at: 1663597233, - last_contact_reply_at: 1663597233, - last_admin_reply_at: 1663597233, - last_close_at: 1663597233, - last_closed_by_id: "c3po", - count_reopens: 1, - count_assignments: 1, - count_conversation_parts: 1, - assigned_team_first_response_time_by_team: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - assigned_team_first_response_time_in_office_hours: [ - { - team_id: 100, - team_name: "Team One", - response_time: 2310, - }, - ], - handling_time: 2310, - adjusted_handling_time: 1800, - }, - conversation_parts: { - type: "conversation_part.list", - conversation_parts: [ - { - type: "conversation_part", - id: "149", - part_type: "open", - body: "

This message was deleted

", - created_at: 1734537722, - updated_at: 1734537724, - notified_at: 1734537722, - author: { - type: "user", - id: "6762f1f81bb69f9f2193bc09", - name: "Joe Bloggs", - email: "joe@bloggs.com", - from_ai_agent: true, - is_ai_answer: false, - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: true, - metadata: { - quick_reply_uuid: "123e4567-e89b-12d3-a456-426614174000", - }, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ai_agent_participated: false, - ai_agent: { - source_type: "essentials_plan_setup", - source_title: "My AI Workflow", - last_answer_type: "ai_answer", - resolution_state: "assumed_resolution", - rating: 4, - rating_remark: "Very helpful!", - created_at: 1663597260, - updated_at: 1663597260, - content_sources: { - type: "content_source.list", - total_count: 1, - content_sources: [ - { - url: "/fin-ai-agent/content?content=content_snippet&id=3234924", - title: "My internal content snippet", - locale: "en", - }, - ], - }, - }, - }); - }); - - test("redactConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("redactConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/redact") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.redactConversation({ - type: "conversation_part", - conversation_id: "conversation_id", - conversation_part_id: "conversation_part_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("convertConversationToTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "53" }; - const rawResponseBody = { - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { key: "value" }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.convertConversationToTicket({ - id: 1, - ticket_type_id: "53", - }); - expect(response).toEqual({ - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { - key: "value", - }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2041bb69f9f2193bc0c", - external_id: "70", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }); - }); - - test("convertConversationToTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "54" }; - const rawResponseBody = { - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { key: "value" }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [{ type: "contact", id: "6762f2041bb69f9f2193bc0c", external_id: "70" }], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.conversations.convertConversationToTicket({ - id: 1, - ticket_type_id: "54", - }); - expect(response).toEqual({ - type: "ticket", - id: "611", - ticket_id: "22", - category: "Customer", - ticket_attributes: { - key: "value", - }, - ticket_state: { - type: "ticket_state", - id: "7493", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "53", - category: "Customer", - name: "my-ticket-type-1", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id442_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537737, - updated_at: 1734537737, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2041bb69f9f2193bc0c", - external_id: "70", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537732, - updated_at: 1734537737, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "151", - part_type: "comment", - body: "

Comment for message

", - created_at: 1734537732, - updated_at: 1734537732, - author: { - type: "user", - id: "6762f2041bb69f9f2193bc0c", - name: "Joe Bloggs", - email: "joe@bloggs.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "152", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537737, - updated_at: 1734537737, - author: { - type: "bot", - id: "991267767", - name: "Fin", - email: "operator+this_is_an_id442_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 2, - }, - is_shared: true, - }); - }); - - test("convertConversationToTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/1/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.conversations.convertConversationToTicket({ - id: 1, - ticket_type_id: "ticket_type_id", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); -}); diff --git a/tests/wire/unstable/customChannelEvents.test.ts b/tests/wire/unstable/customChannelEvents.test.ts deleted file mode 100644 index bb810951..00000000 --- a/tests/wire/unstable/customChannelEvents.test.ts +++ /dev/null @@ -1,796 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CustomChannelEventsClient", () => { - test("notifyNewConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "evt_12345", - external_conversation_id: "conv_67890", - contact: { type: "user", external_id: "user_001", name: "Jane Doe", email: "jane.doe@example.com" }, - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyNewConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyNewConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyNewConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyNewConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_conversation") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewConversation({ - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyNewMessage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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.", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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.", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyNewMessage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyNewMessage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyNewMessage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyNewMessage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_new_message") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyNewMessage({ - body: "body", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyQuickReplySelected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyQuickReplySelected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyQuickReplySelected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyQuickReplySelected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyQuickReplySelected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_quick_reply_selected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyQuickReplySelected({ - quick_reply_option_id: "quick_reply_option_id", - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("notifyAttributeCollected (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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" }, - }; - const rawResponseBody = { - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - external_conversation_id: "customer_conversation_id_12", - conversation_id: "intercom_conversation_id_34", - external_contact_id: "customer_contact_id_56", - contact_id: "intercom_contact_id_79", - }); - }); - - test("notifyAttributeCollected (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("notifyAttributeCollected (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("notifyAttributeCollected (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("notifyAttributeCollected (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - attribute: { id: "id", value: "value" }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { type: "user", external_id: "external_id" }, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_channel_events/notify_attribute_collected") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customChannelEvents.notifyAttributeCollected({ - attribute: { - id: "id", - value: "value", - }, - event_id: "event_id", - external_conversation_id: "external_conversation_id", - contact: { - type: "user", - external_id: "external_id", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/unstable/customObjectInstances.test.ts b/tests/wire/unstable/customObjectInstances.test.ts deleted file mode 100644 index 6f46b5a0..00000000 --- a/tests/wire/unstable/customObjectInstances.test.ts +++ /dev/null @@ -1,475 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CustomObjectInstancesClient", () => { - test("getCustomObjectInstancesByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .get("/custom_object_instances/Order") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - external_id: "external_id", - }); - expect(response).toEqual({ - id: "24", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537748, - updated_at: 1734537748, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("getCustomObjectInstancesByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getCustomObjectInstancesByExternalId (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("createCustomObjectInstances (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - const rawResponseBody = { - id: "22", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1734537745, - updated_at: 1734537745, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .post("/custom_object_instances/Order") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - id: "22", - external_id: "123", - external_created_at: 1392036272, - external_updated_at: 1392036272, - created_at: 1734537745, - updated_at: 1734537745, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("createCustomObjectInstances (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/custom_object_instances/custom_object_type_identifier") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.createCustomObjectInstances({ - custom_object_type_identifier: "custom_object_type_identifier", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createCustomObjectInstances (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/custom_object_instances/custom_object_type_identifier") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.createCustomObjectInstances({ - custom_object_type_identifier: "custom_object_type_identifier", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteCustomObjectInstancesById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { object: "Order", id: "26", deleted: true }; - server - .mockEndpoint() - .delete("/custom_object_instances/Order") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - external_id: "external_id", - }); - expect(response).toEqual({ - object: "Order", - id: "26", - deleted: true, - }); - }); - - test("deleteCustomObjectInstancesById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteCustomObjectInstancesById (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - external_id: "external_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("getCustomObjectInstancesById (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "25", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537750, - updated_at: 1734537750, - type: "Order", - custom_attributes: { order_number: "ORDER-12345", total_amount: "custom_attributes" }, - }; - server - .mockEndpoint() - .get("/custom_object_instances/Order/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "Order", - id: "id", - }); - expect(response).toEqual({ - id: "25", - external_id: "123", - external_created_at: 1571672154, - external_updated_at: 1571672154, - created_at: 1734537750, - updated_at: 1734537750, - type: "Order", - custom_attributes: { - order_number: "ORDER-12345", - total_amount: "custom_attributes", - }, - }); - }); - - test("getCustomObjectInstancesById (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getCustomObjectInstancesById (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/custom_object_instances/custom_object_type_identifier/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.getCustomObjectInstancesById({ - custom_object_type_identifier: "custom_object_type_identifier", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteCustomObjectInstancesByExternalId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { object: "Order", id: "26", deleted: true }; - server - .mockEndpoint() - .delete("/custom_object_instances/Order/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "Order", - id: "id", - }); - expect(response).toEqual({ - object: "Order", - id: "26", - deleted: true, - }); - }); - - test("deleteCustomObjectInstancesByExternalId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteCustomObjectInstancesByExternalId (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/custom_object_instances/custom_object_type_identifier/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ - custom_object_type_identifier: "custom_object_type_identifier", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/dataAttributes.test.ts b/tests/wire/unstable/dataAttributes.test.ts deleted file mode 100644 index 40902954..00000000 --- a/tests/wire/unstable/dataAttributes.test.ts +++ /dev/null @@ -1,992 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("DataAttributesClient", () => { - test("lisDataAttributes (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "name", - label: "Company name", - description: "The name of a company", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "company_id", - full_name: "company_id", - label: "Company ID", - description: "A number identifying a company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "last_request_at", - full_name: "last_request_at", - label: "Company last seen", - description: "The last day anyone from a company visited your site or app", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "remote_created_at", - full_name: "remote_created_at", - label: "Company created at", - description: "The day a company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "user_count", - full_name: "user_count", - label: "People", - description: "The number of people in a company", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "session_count", - full_name: "session_count", - label: "Company web sessions", - description: "All visits from anyone in a company to your product's site or app", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "plan.name", - label: "Plan", - description: "A specific plan or level within your product that companies have signed up to", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "monthly_spend", - full_name: "monthly_spend", - label: "Monthly Spend", - description: "The monthly revenue you receive from a company", - data_type: "float", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "size", - full_name: "size", - label: "Company size", - description: "The number of people employed in this company, expressed as a single number", - data_type: "integer", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "industry", - full_name: "industry", - label: "Company industry", - description: "The category or domain this company belongs to e.g. 'ecommerce' or 'SaaS'", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "website", - full_name: "website", - label: "Company website", - description: "The web address for the company's primary marketing site", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 34, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: - "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537753, - updated_at: 1734537753, - admin_id: "991267784", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "id", - label: "ID", - description: "The Intercom defined id representing the company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "created_at", - full_name: "created_at", - label: "Created at", - description: "The time the company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "updated_at", - full_name: "updated_at", - label: "Updated at", - description: "The last time the company was updated", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "plan.id", - label: "Plan ID", - description: "The Intercom defined id representing the plan", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "app_id", - full_name: "app_id", - label: "App ID", - description: "The Intercom defined id representing the app", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - ], - }; - server.mockEndpoint().get("/data_attributes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.dataAttributes.lisDataAttributes({ - model: "contact", - include_archived: true, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "name", - label: "Company name", - description: "The name of a company", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "company_id", - full_name: "company_id", - label: "Company ID", - description: "A number identifying a company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "last_request_at", - full_name: "last_request_at", - label: "Company last seen", - description: "The last day anyone from a company visited your site or app", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "remote_created_at", - full_name: "remote_created_at", - label: "Company created at", - description: "The day a company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "user_count", - full_name: "user_count", - label: "People", - description: "The number of people in a company", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "session_count", - full_name: "session_count", - label: "Company web sessions", - description: "All visits from anyone in a company to your product's site or app", - data_type: "integer", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "name", - full_name: "plan.name", - label: "Plan", - description: "A specific plan or level within your product that companies have signed up to", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "monthly_spend", - full_name: "monthly_spend", - label: "Monthly Spend", - description: "The monthly revenue you receive from a company", - data_type: "float", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "size", - full_name: "size", - label: "Company size", - description: "The number of people employed in this company, expressed as a single number", - data_type: "integer", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "industry", - full_name: "industry", - label: "Company industry", - description: "The category or domain this company belongs to e.g. 'ecommerce' or 'SaaS'", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "website", - full_name: "website", - label: "Company website", - description: "The web address for the company's primary marketing site", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 34, - model: "company", - name: "The One Ring", - full_name: "custom_attributes.The One Ring", - label: "The One Ring", - description: - "One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them.", - data_type: "string", - options: ["true", "false"], - api_writable: true, - messenger_writable: true, - ui_writable: false, - custom: true, - archived: false, - created_at: 1734537753, - updated_at: 1734537753, - admin_id: "991267784", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "id", - label: "ID", - description: "The Intercom defined id representing the company", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "created_at", - full_name: "created_at", - label: "Created at", - description: "The time the company was added to Intercom", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "updated_at", - full_name: "updated_at", - label: "Updated at", - description: "The last time the company was updated", - data_type: "date", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "id", - full_name: "plan.id", - label: "Plan ID", - description: "The Intercom defined id representing the plan", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - { - type: "data_attribute", - id: 12878, - model: "company", - name: "app_id", - full_name: "app_id", - label: "App ID", - description: "The Intercom defined id representing the app", - data_type: "string", - options: ["true", "false"], - api_writable: false, - messenger_writable: true, - ui_writable: false, - custom: false, - archived: false, - created_at: 1671028894, - updated_at: 1671028894, - admin_id: "5712945", - }, - ], - }); - }); - - test("lisDataAttributes (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/data_attributes").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.dataAttributes.lisDataAttributes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createDataAttribute (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - type: "data_attribute", - id: 1, - model: "contact", - name: "name", - full_name: "full_name", - label: "label", - description: "description", - data_type: "string", - options: ["options", "options"], - api_writable: true, - messenger_writable: true, - ui_writable: true, - custom: true, - archived: true, - created_at: 1, - updated_at: 1, - admin_id: "admin_id", - }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.dataAttributes.createDataAttribute({ - key: "value", - }); - expect(response).toEqual({ - type: "data_attribute", - id: 1, - model: "contact", - name: "name", - full_name: "full_name", - label: "label", - description: "description", - data_type: "string", - options: ["options", "options"], - api_writable: true, - messenger_writable: true, - ui_writable: true, - custom: true, - archived: true, - created_at: 1, - updated_at: 1, - admin_id: "admin_id", - }); - }); - - test("createDataAttribute (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.createDataAttribute({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createDataAttribute (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/data_attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.createDataAttribute({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateDataAttribute (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - type: "data_attribute", - id: 1, - model: "contact", - name: "name", - full_name: "full_name", - label: "label", - description: "description", - data_type: "string", - options: ["options", "options"], - api_writable: true, - messenger_writable: true, - ui_writable: true, - custom: true, - archived: true, - created_at: 1, - updated_at: 1, - admin_id: "admin_id", - }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.dataAttributes.updateDataAttribute({ - id: 1, - body: { - key: "value", - }, - }); - expect(response).toEqual({ - type: "data_attribute", - id: 1, - model: "contact", - name: "name", - full_name: "full_name", - label: "label", - description: "description", - data_type: "string", - options: ["options", "options"], - api_writable: true, - messenger_writable: true, - ui_writable: true, - custom: true, - archived: true, - created_at: 1, - updated_at: 1, - admin_id: "admin_id", - }); - }); - - test("updateDataAttribute (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ - id: 1, - body: { - key: "value", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("updateDataAttribute (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ - id: 1, - body: { - key: "value", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateDataAttribute (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ - id: 1, - body: { - key: "value", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateDataAttribute (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/data_attributes/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataAttributes.updateDataAttribute({ - id: 1, - body: { - key: "value", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/unstable/dataEvents.test.ts b/tests/wire/unstable/dataEvents.test.ts deleted file mode 100644 index 14d6052a..00000000 --- a/tests/wire/unstable/dataEvents.test.ts +++ /dev/null @@ -1,164 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("DataEventsClient", () => { - test("lisDataEvents (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "event.summary", - email: "email", - intercom_user_id: "intercom_user_id", - user_id: "user_id", - events: [ - { name: "name", first: "first", last: "last", count: 1, description: "description" }, - { name: "name", first: "first", last: "last", count: 1, description: "description" }, - ], - }; - server.mockEndpoint().get("/events").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.dataEvents.lisDataEvents({ - filter: { - user_id: "user_id", - }, - type: "type", - }); - expect(response).toEqual({ - type: "event.summary", - email: "email", - intercom_user_id: "intercom_user_id", - user_id: "user_id", - events: [ - { - name: "name", - first: "first", - last: "last", - count: 1, - description: "description", - }, - { - name: "name", - first: "first", - last: "last", - count: 1, - description: "description", - }, - ], - }); - }); - - test("lisDataEvents (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/events").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.dataEvents.lisDataEvents({ - filter: { - user_id: "user_id", - }, - type: "type", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createDataEvent (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - - server.mockEndpoint().post("/events").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - - const response = await client.unstable.dataEvents.createDataEvent({ - key: "value", - }); - expect(response).toEqual(undefined); - }); - - test("createDataEvent (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/events") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataEvents.createDataEvent({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("dataEventSummaries (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - - server.mockEndpoint().post("/events/summaries").jsonBody(rawRequestBody).respondWith().statusCode(200).build(); - - const response = await client.unstable.dataEvents.dataEventSummaries(); - expect(response).toEqual(undefined); - }); - - test("dataEventSummaries (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/events/summaries") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.dataEvents.dataEventSummaries(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/dataExport.test.ts b/tests/wire/unstable/dataExport.test.ts deleted file mode 100644 index 7db13db4..00000000 --- a/tests/wire/unstable/dataExport.test.ts +++ /dev/null @@ -1,127 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("DataExportClient", () => { - test("createDataExport", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { created_at_after: 1734519776, created_at_before: 1734537776 }; - const rawResponseBody = { - job_identfier: "orzzsbd7hk67xyu", - status: "pending", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .post("/export/content/data") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.dataExport.createDataExport({ - created_at_after: 1734519776, - created_at_before: 1734537776, - }); - expect(response).toEqual({ - job_identfier: "orzzsbd7hk67xyu", - status: "pending", - download_expires_at: "", - download_url: "", - }); - }); - - test("getDataExport", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - job_identfier: "orzzsbd7hk67xyu", - status: "pending", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .get("/export/content/data/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.dataExport.getDataExport({ - job_identifier: "job_identifier", - }); - expect(response).toEqual({ - job_identfier: "orzzsbd7hk67xyu", - status: "pending", - download_expires_at: "", - download_url: "", - }); - }); - - test("cancelDataExport", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - job_identfier: "orzzsbd7hk67xyu", - status: "canceled", - download_expires_at: "", - download_url: "", - }; - server - .mockEndpoint() - .post("/export/cancel/job_identifier") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.dataExport.cancelDataExport({ - job_identifier: "job_identifier", - }); - expect(response).toEqual({ - job_identfier: "orzzsbd7hk67xyu", - status: "canceled", - download_expires_at: "", - download_url: "", - }); - }); - - test("downloadDataExport", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().get("/download/content/data/job_identifier").respondWith().statusCode(200).build(); - - const response = await client.unstable.dataExport.downloadDataExport({ - job_identifier: "job_identifier", - }); - expect(response).toEqual(undefined); - }); -}); diff --git a/tests/wire/unstable/emails.test.ts b/tests/wire/unstable/emails.test.ts deleted file mode 100644 index 95a02bd0..00000000 --- a/tests/wire/unstable/emails.test.ts +++ /dev/null @@ -1,174 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("EmailsClient", () => { - test("listEmails (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "email_setting", - id: "1", - email: "support@company.com", - verified: true, - domain: "company.com", - brand_id: "9", - forwarding_enabled: true, - forwarded_email_last_received_at: 1710498600, - created_at: 1692530400, - updated_at: 1710498600, - }, - { - type: "email_setting", - id: "2", - email: "hello@company.com", - verified: true, - domain: "company.com", - brand_id: "10", - forwarding_enabled: false, - forwarded_email_last_received_at: 1710498600, - created_at: 1683729000, - updated_at: 1701424500, - }, - ], - }; - server.mockEndpoint().get("/emails").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.emails.listEmails(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "email_setting", - id: "1", - email: "support@company.com", - verified: true, - domain: "company.com", - brand_id: "9", - forwarding_enabled: true, - forwarded_email_last_received_at: 1710498600, - created_at: 1692530400, - updated_at: 1710498600, - }, - { - type: "email_setting", - id: "2", - email: "hello@company.com", - verified: true, - domain: "company.com", - brand_id: "10", - forwarding_enabled: false, - forwarded_email_last_received_at: 1710498600, - created_at: 1683729000, - updated_at: 1701424500, - }, - ], - }); - }); - - test("listEmails (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/emails").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.emails.listEmails(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveEmail (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "email_setting", - id: "10", - email: "support@company.com", - verified: true, - domain: "company.com", - brand_id: "15", - forwarding_enabled: true, - forwarded_email_last_received_at: 1710498600, - created_at: 1692530400, - updated_at: 1710498600, - }; - server.mockEndpoint().get("/emails/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.emails.retrieveEmail({ - id: "id", - }); - expect(response).toEqual({ - type: "email_setting", - id: "10", - email: "support@company.com", - verified: true, - domain: "company.com", - brand_id: "15", - forwarding_enabled: true, - forwarded_email_last_received_at: 1710498600, - created_at: 1692530400, - updated_at: 1710498600, - }); - }); - - test("retrieveEmail (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/emails/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.emails.retrieveEmail({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveEmail (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/emails/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.emails.retrieveEmail({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/export.test.ts b/tests/wire/unstable/export.test.ts deleted file mode 100644 index 0027d596..00000000 --- a/tests/wire/unstable/export.test.ts +++ /dev/null @@ -1,201 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("ExportClient", () => { - test("enqueueANewReportingDataExportJob (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000, - }; - const rawResponseBody = { - job_identifier: "job1", - status: "pending", - download_url: "download_url", - download_expires_at: "download_expires_at", - }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.export.enqueueANewReportingDataExportJob({ - dataset_id: "conversation", - attribute_ids: ["conversation_id", "conversation_started_at"], - start_time: 1717490000, - end_time: 1717510000, - }); - expect(response).toEqual({ - job_identifier: "job1", - status: "pending", - download_url: "download_url", - download_expires_at: "download_expires_at", - }); - }); - - test("enqueueANewReportingDataExportJob (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("enqueueANewReportingDataExportJob (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("enqueueANewReportingDataExportJob (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/export/reporting_data/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.export.enqueueANewReportingDataExportJob({ - dataset_id: "dataset_id", - attribute_ids: ["attribute_ids", "attribute_ids"], - start_time: 1000000, - end_time: 1000000, - }); - }).rejects.toThrow(Intercom.unstable.TooManyRequestsError); - }); - - test("listAvailableDatasetsAndAttributes", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - id: "conversation", - name: "Conversation", - description: "Conversation-level details: status, channel, assignee.", - default_time_attribute_id: "conversation_started_at", - attributes: [{ id: "conversation_id", name: "Conversation ID" }], - }, - ], - }; - server - .mockEndpoint() - .get("/export/reporting_data/get_datasets") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.export.listAvailableDatasetsAndAttributes(); - expect(response).toEqual({ - type: "list", - data: [ - { - id: "conversation", - name: "Conversation", - description: "Conversation-level details: status, channel, assignee.", - default_time_attribute_id: "conversation_started_at", - attributes: [ - { - id: "conversation_id", - name: "Conversation ID", - }, - ], - }, - ], - }); - }); -}); diff --git a/tests/wire/unstable/helpCenter.test.ts b/tests/wire/unstable/helpCenter.test.ts deleted file mode 100644 index 7e4acacd..00000000 --- a/tests/wire/unstable/helpCenter.test.ts +++ /dev/null @@ -1,1933 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("HelpCenterClient", () => { - test("listAllCollections (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 1, - }, - total_count: 2, - data: [ - { - id: "159", - workspace_id: "this_is_an_id96_that_should_be_at_least_4", - name: "English collection title", - description: "english collection description", - created_at: 1734537309, - updated_at: 1734537309, - url: "http://help-center.test/myapp-96/collection-17", - icon: "bookmark", - order: 17, - default_locale: "en", - parent_id: "6871118", - help_center_id: 79, - }, - { - id: "160", - workspace_id: "this_is_an_id96_that_should_be_at_least_4", - name: "English section title", - description: "Default language description", - created_at: 1734537309, - updated_at: 1734537309, - url: "http://help-center.test/myapp-96/section-1", - icon: "bookmark", - order: 1, - default_locale: "en", - parent_id: "159", - help_center_id: 1, - }, - ], - }; - server - .mockEndpoint() - .get("/help_center/collections") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.listAllCollections(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 1, - }, - total_count: 2, - data: [ - { - id: "159", - workspace_id: "this_is_an_id96_that_should_be_at_least_4", - name: "English collection title", - description: "english collection description", - created_at: 1734537309, - updated_at: 1734537309, - url: "http://help-center.test/myapp-96/collection-17", - icon: "bookmark", - order: 17, - default_locale: "en", - parent_id: "6871118", - help_center_id: 79, - }, - { - id: "160", - workspace_id: "this_is_an_id96_that_should_be_at_least_4", - name: "English section title", - description: "Default language description", - created_at: 1734537309, - updated_at: 1734537309, - url: "http://help-center.test/myapp-96/section-1", - icon: "bookmark", - order: 1, - default_locale: "en", - parent_id: "159", - help_center_id: 1, - }, - ], - }); - }); - - test("listAllCollections (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/collections") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.listAllCollections(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createCollection (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Thanks for everything" }; - const rawResponseBody = { - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 81, - }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.createCollection({ - name: "Thanks for everything", - }); - expect(response).toEqual({ - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 81, - }); - }); - - test("createCollection (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "collection 51", description: "Missing required parameter" }; - const rawResponseBody = { - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 81, - }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.createCollection({ - name: "collection 51", - description: "Missing required parameter", - }); - expect(response).toEqual({ - id: "165", - workspace_id: "this_is_an_id100_that_should_be_at_least_", - name: "Thanks for everything", - description: "", - created_at: 1734537312, - updated_at: 1734537312, - url: "http://help-center.test/myapp-100/", - icon: "book-bookmark", - order: 1, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 81, - }); - }); - - test("createCollection (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.createCollection({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createCollection (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/help_center/collections") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.createCollection({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveCollection (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "170", - workspace_id: "this_is_an_id106_that_should_be_at_least_", - name: "English collection title", - description: "english collection description", - created_at: 1734537315, - updated_at: 1734537315, - url: "http://help-center.test/myapp-106/collection-22", - icon: "bookmark", - order: 22, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 84, - }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.retrieveCollection({ - id: 1, - }); - expect(response).toEqual({ - id: "170", - workspace_id: "this_is_an_id106_that_should_be_at_least_", - name: "English collection title", - description: "english collection description", - created_at: 1734537315, - updated_at: 1734537315, - url: "http://help-center.test/myapp-106/collection-22", - icon: "bookmark", - order: 22, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 84, - }); - }); - - test("retrieveCollection (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.retrieveCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveCollection (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/help_center/collections/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.retrieveCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateCollection (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Update collection name" }; - const rawResponseBody = { - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 87, - }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.updateCollection({ - id: 1, - name: "Update collection name", - }); - expect(response).toEqual({ - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 87, - }); - }); - - test("updateCollection (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Update collection name" }; - const rawResponseBody = { - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { type: "group_content", name: "Collection name", description: " Collection description" }, - bg: { type: "group_content", name: "Collection name", description: " Collection description" }, - bs: { type: "group_content", name: "Collection name", description: " Collection description" }, - ca: { type: "group_content", name: "Collection name", description: " Collection description" }, - cs: { type: "group_content", name: "Collection name", description: " Collection description" }, - da: { type: "group_content", name: "Collection name", description: " Collection description" }, - de: { type: "group_content", name: "Collection name", description: " Collection description" }, - el: { type: "group_content", name: "Collection name", description: " Collection description" }, - en: { type: "group_content", name: "Collection name", description: " Collection description" }, - es: { type: "group_content", name: "Collection name", description: " Collection description" }, - et: { type: "group_content", name: "Collection name", description: " Collection description" }, - fi: { type: "group_content", name: "Collection name", description: " Collection description" }, - fr: { type: "group_content", name: "Collection name", description: " Collection description" }, - he: { type: "group_content", name: "Collection name", description: " Collection description" }, - hr: { type: "group_content", name: "Collection name", description: " Collection description" }, - hu: { type: "group_content", name: "Collection name", description: " Collection description" }, - id: { type: "group_content", name: "Collection name", description: " Collection description" }, - it: { type: "group_content", name: "Collection name", description: " Collection description" }, - ja: { type: "group_content", name: "Collection name", description: " Collection description" }, - ko: { type: "group_content", name: "Collection name", description: " Collection description" }, - lt: { type: "group_content", name: "Collection name", description: " Collection description" }, - lv: { type: "group_content", name: "Collection name", description: " Collection description" }, - mn: { type: "group_content", name: "Collection name", description: " Collection description" }, - nb: { type: "group_content", name: "Collection name", description: " Collection description" }, - nl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pl: { type: "group_content", name: "Collection name", description: " Collection description" }, - pt: { type: "group_content", name: "Collection name", description: " Collection description" }, - ro: { type: "group_content", name: "Collection name", description: " Collection description" }, - ru: { type: "group_content", name: "Collection name", description: " Collection description" }, - sl: { type: "group_content", name: "Collection name", description: " Collection description" }, - sr: { type: "group_content", name: "Collection name", description: " Collection description" }, - sv: { type: "group_content", name: "Collection name", description: " Collection description" }, - tr: { type: "group_content", name: "Collection name", description: " Collection description" }, - vi: { type: "group_content", name: "Collection name", description: " Collection description" }, - "pt-BR": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-CN": { type: "group_content", name: "Collection name", description: " Collection description" }, - "zh-TW": { type: "group_content", name: "Collection name", description: " Collection description" }, - }, - parent_id: "6871118", - help_center_id: 87, - }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.updateCollection({ - id: 1, - name: "Update collection name", - }); - expect(response).toEqual({ - id: "176", - workspace_id: "this_is_an_id112_that_should_be_at_least_", - name: "Update collection name", - description: "english collection description", - created_at: 1734537318, - updated_at: 1734537319, - url: "http://help-center.test/myapp-112/collection-25", - icon: "folder", - order: 25, - default_locale: "en", - translated_content: { - type: "group_translated_content", - ar: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bg: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - bs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ca: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - cs: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - da: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - de: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - el: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - en: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - es: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - et: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - fr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - he: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - hu: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - id: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - it: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ja: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ko: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - lv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - mn: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nb: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - nl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - pt: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ro: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - ru: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sl: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - sv: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - tr: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - vi: { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "pt-BR": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-CN": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - "zh-TW": { - type: "group_content", - name: "Collection name", - description: " Collection description", - }, - }, - parent_id: "6871118", - help_center_id: 87, - }); - }); - - test("updateCollection (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.updateCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateCollection (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/help_center/collections/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.updateCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteCollection (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "182", object: "collection", deleted: true }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.deleteCollection({ - id: 1, - }); - expect(response).toEqual({ - id: "182", - object: "collection", - deleted: true, - }); - }); - - test("deleteCollection (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.deleteCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteCollection (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/help_center/collections/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.deleteCollection({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("retrieveHelpCenter (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "93", - workspace_id: "this_is_an_id124_that_should_be_at_least_", - created_at: 1734537325, - updated_at: 1734537325, - identifier: "help-center-1", - website_turned_on: false, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.retrieveHelpCenter({ - id: 1, - }); - expect(response).toEqual({ - id: "93", - workspace_id: "this_is_an_id124_that_should_be_at_least_", - created_at: 1734537325, - updated_at: 1734537325, - identifier: "help-center-1", - website_turned_on: false, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }); - }); - - test("retrieveHelpCenter (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.retrieveHelpCenter({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveHelpCenter (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/help_center/help_centers/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.retrieveHelpCenter({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listHelpCenters (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - id: "123", - workspace_id: "hfi1bx4l", - created_at: 1672928359, - updated_at: 1672928610, - identifier: "intercom", - website_turned_on: true, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }, - ], - }; - server - .mockEndpoint() - .get("/help_center/help_centers") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.helpCenter.listHelpCenters(); - expect(response).toEqual({ - type: "list", - data: [ - { - id: "123", - workspace_id: "hfi1bx4l", - created_at: 1672928359, - updated_at: 1672928610, - identifier: "intercom", - website_turned_on: true, - display_name: "Intercom Help Center", - url: "https://help.mycompany.com", - custom_domain: "help.mycompany.com", - }, - ], - }); - }); - - test("listHelpCenters (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/help_center/help_centers") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.helpCenter.listHelpCenters(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/internalArticles.test.ts b/tests/wire/unstable/internalArticles.test.ts deleted file mode 100644 index b8d9b058..00000000 --- a/tests/wire/unstable/internalArticles.test.ts +++ /dev/null @@ -1,655 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("InternalArticlesClient", () => { - test("listInternalArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "internal_article", - id: "39", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }; - server.mockEndpoint().get("/internal_articles").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.internalArticles.listInternalArticles(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 25, - total_pages: 1, - }, - total_count: 1, - data: [ - { - type: "internal_article", - id: "39", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }); - }); - - test("listInternalArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/internal_articles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.internalArticles.listInternalArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252, - }; - const rawResponseBody = { - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .post("/internal_articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Article", - author_id: 991266252, - owner_id: 991266252, - }); - expect(response).toEqual({ - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("createInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Thanks for everything", - body: "Body of the Internal Article", - author_id: 1295, - owner_id: 1295, - }; - const rawResponseBody = { - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .post("/internal_articles") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.createInternalArticle({ - title: "Thanks for everything", - body: "Body of the Internal Article", - author_id: 1295, - owner_id: 1295, - }); - expect(response).toEqual({ - type: "internal_article", - id: "42", - title: "Thanks for everything", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("createInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/internal_articles") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createInternalArticle (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/internal_articles") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.createInternalArticle(undefined); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "internal_article", - id: "45", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.retrieveInternalArticle({ - id: 1, - }); - expect(response).toEqual({ - type: "internal_article", - id: "45", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("retrieveInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.retrieveInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/internal_articles/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.retrieveInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("updateInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "Christmas is here!", body: "

New gifts in store for the jolly season

" }; - const rawResponseBody = { - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - }); - expect(response).toEqual({ - type: "internal_article", - id: "48", - title: "title", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }); - }); - - test("updateInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateInternalArticle (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/internal_articles/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.updateInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteInternalArticle (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "51", object: "internal_article", deleted: true }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.deleteInternalArticle({ - id: 1, - }); - expect(response).toEqual({ - id: "51", - object: "internal_article", - deleted: true, - }); - }); - - test("deleteInternalArticle (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.deleteInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteInternalArticle (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/internal_articles/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.deleteInternalArticle({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("searchInternalArticles (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - total_count: 1, - data: { - internal_articles: [ - { - id: "55", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - }; - server - .mockEndpoint() - .get("/internal_articles/search") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.internalArticles.searchInternalArticles({ - folder_id: "folder_id", - }); - expect(response).toEqual({ - type: "list", - total_count: 1, - data: { - internal_articles: [ - { - id: "55", - body: "Body of the Article", - owner_id: 991266252, - author_id: 991266252, - created_at: 1672928359, - updated_at: 1672928610, - locale: "en", - }, - ], - }, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - }); - }); - - test("searchInternalArticles (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/internal_articles/search") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.internalArticles.searchInternalArticles(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/jobs.test.ts b/tests/wire/unstable/jobs.test.ts deleted file mode 100644 index 7e511aee..00000000 --- a/tests/wire/unstable/jobs.test.ts +++ /dev/null @@ -1,79 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("JobsClient", () => { - test("status (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "job", - id: "2", - url: "https://api.intercom.io/jobs/status/20", - status: "success", - resource_type: "ticket", - resource_id: "20", - resource_url: "https://api.intercom.io/tickets/20", - }; - server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.jobs.status({ - id: "id", - }); - expect(response).toEqual({ - type: "job", - id: "2", - url: "https://api.intercom.io/jobs/status/20", - status: "success", - resource_type: "ticket", - resource_id: "20", - resource_url: "https://api.intercom.io/tickets/20", - }); - }); - - test("status (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.jobs.status({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("status (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/jobs/status/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.jobs.status({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/macros.test.ts b/tests/wire/unstable/macros.test.ts deleted file mode 100644 index 04168725..00000000 --- a/tests/wire/unstable/macros.test.ts +++ /dev/null @@ -1,699 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("MacrosClient", () => { - test("listMacros (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "123", - name: "Order Status Update", - body: '

Hi , your order # is ready for pickup!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order #{{order.number}} is ready for pickup!', - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - { - type: "macro", - id: "456", - name: "Welcome Message", - body: '

Welcome to our support! I\'m . How can I help you today?

', - body_text: "Welcome to our support! I'm {{teammate.name}}. How can I help you today?", - created_at: "2025-07-21T14:44:35Z", - updated_at: "2025-07-21T14:44:35Z", - visible_to: "specific_teams", - visible_to_team_ids: ["789", "101"], - available_on: ["inbox"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "123", - name: "Order Status Update", - body: '

Hi , your order # is ready for pickup!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order #{{order.number}} is ready for pickup!', - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - { - type: "macro", - id: "456", - name: "Welcome Message", - body: '

Welcome to our support! I\'m . How can I help you today?

', - body_text: "Welcome to our support! I'm {{teammate.name}}. How can I help you today?", - created_at: "2025-07-21T14:44:35Z", - updated_at: "2025-07-21T14:44:35Z", - visible_to: "specific_teams", - visible_to_team_ids: ["789", "101"], - available_on: ["inbox"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - }, - }, - }); - }); - - test("listMacros (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "789", - name: "Refund Process", - body: '

I understand you\'d like a refund for order #. The refund will be processed within 3-5 business days.

', - body_text: - "I understand you'd like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days.", - created_at: "2025-07-21T07:15:34Z", - updated_at: "2025-07-21T07:15:34Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - { - type: "macro", - id: "101", - name: "Product Inquiry Response", - body: '

Thank you for your interest in . I\'d be happy to provide more information!

', - body_text: - 'Thank you for your interest in {{product.name|fallback:"our products"}}. I\'d be happy to provide more information!', - created_at: "2025-07-20T05:33:20Z", - updated_at: "2025-07-21T10:00:00Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0MDAwMDAuMCwgIjEwMSJd" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "789", - name: "Refund Process", - body: '

I understand you\'d like a refund for order #. The refund will be processed within 3-5 business days.

', - body_text: - "I understand you'd like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days.", - created_at: "2025-07-21T07:15:34Z", - updated_at: "2025-07-21T07:15:34Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - { - type: "macro", - id: "101", - name: "Product Inquiry Response", - body: '

Thank you for your interest in . I\'d be happy to provide more information!

', - body_text: - 'Thank you for your interest in {{product.name|fallback:"our products"}}. I\'d be happy to provide more information!', - created_at: "2025-07-20T05:33:20Z", - updated_at: "2025-07-21T10:00:00Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0MDAwMDAuMCwgIjEwMSJd", - }, - }, - }); - }); - - test("listMacros (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "234", - name: "Shipping Update Template", - body: '

Your order has been shipped via . Tracking number:

', - body_text: - 'Your order has been shipped via {{shipping.carrier|fallback:"our shipping partner"}}. Tracking number: {{shipping.tracking_number}}', - created_at: "2025-07-22T05:31:01Z", - updated_at: "2025-07-22T18:45:12Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "234", - name: "Shipping Update Template", - body: '

Your order has been shipped via . Tracking number:

', - body_text: - 'Your order has been shipped via {{shipping.carrier|fallback:"our shipping partner"}}. Tracking number: {{shipping.tracking_number}}', - created_at: "2025-07-22T05:31:01Z", - updated_at: "2025-07-22T18:45:12Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - }, - }, - }); - }); - - test("listMacros (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "567", - name: "Account Status Review", - body: '

Hi ,

Your account status:

Last activity:

', - body_text: - 'Hi {{user.first_name|fallback:"there"}},\n\nYour account status: {{user.custom_attributes.account_status|fallback:"pending review"}}\n\nLast activity: {{user.last_seen_at}}', - created_at: "2025-07-21T09:00:00Z", - updated_at: "2025-07-21T09:00:00Z", - visible_to: "specific_teams", - visible_to_team_ids: ["security_team"], - available_on: ["inbox"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "567", - name: "Account Status Review", - body: '

Hi ,

Your account status:

Last activity:

', - body_text: - 'Hi {{user.first_name|fallback:"there"}},\n\nYour account status: {{user.custom_attributes.account_status|fallback:"pending review"}}\n\nLast activity: {{user.last_seen_at}}', - created_at: "2025-07-21T09:00:00Z", - updated_at: "2025-07-21T09:00:00Z", - visible_to: "specific_teams", - visible_to_team_ids: ["security_team"], - available_on: ["inbox"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - }, - }, - }); - }); - - test("listMacros (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "123", - name: "Order Status Update", - body: '

Hi , your order is ready!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!', - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "123", - name: "Order Status Update", - body: '

Hi , your order is ready!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!', - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - }, - }, - }); - }); - - test("listMacros (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "macro", - id: "1001", - name: "Quick Response 1", - body: '

Hi , your order is ready!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!', - created_at: "2025-07-22T11:08:20Z", - updated_at: "2025-07-23T11:08:20Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }, - ], - pages: { type: "pages", per_page: 50, next: { starting_after: "WzE3MTk0OTAxMDAuMCwgIjEwMDIiXQ==" } }, - }; - server.mockEndpoint().get("/macros").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.listMacros({ - per_page: 1, - starting_after: "WzE3MTk0OTM3NTcuMCwgIjEyMyJd", - updated_since: 1000000, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "macro", - id: "1001", - name: "Quick Response 1", - body: '

Hi , your order is ready!

', - body_text: 'Hi {{user.name|fallback:"there"}}, your order is ready!', - created_at: "2025-07-22T11:08:20Z", - updated_at: "2025-07-23T11:08:20Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }, - ], - pages: { - type: "pages", - per_page: 50, - next: { - starting_after: "WzE3MTk0OTAxMDAuMCwgIjEwMDIiXQ==", - }, - }, - }); - }); - - test("listMacros (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/macros").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("listMacros (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/macros").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listMacros (9)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/macros").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.listMacros(); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("getMacro (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "macro", - id: "789", - name: "Refund Process Explanation", - body: '

Hi ,

I understand you\'d like a refund for order #. The refund will be processed within 3-5 business days to your .

Is there anything else I can help you with?

', - body_text: - 'Hi {{user.first_name|fallback:"there"}},\n\nI understand you\'d like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days to your {{user.custom_attributes.payment_method|fallback:"original payment method"}}.\n\nIs there anything else I can help you with?', - created_at: "2025-07-21T14:44:35Z", - updated_at: "2025-07-21T14:44:35Z", - visible_to: "specific_teams", - visible_to_team_ids: ["support_team_1", "support_team_2"], - available_on: ["inbox", "messenger"], - }; - server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.getMacro({ - id: "123", - }); - expect(response).toEqual({ - type: "macro", - id: "789", - name: "Refund Process Explanation", - body: '

Hi ,

I understand you\'d like a refund for order #. The refund will be processed within 3-5 business days to your .

Is there anything else I can help you with?

', - body_text: - 'Hi {{user.first_name|fallback:"there"}},\n\nI understand you\'d like a refund for order #{{conversation.custom_attributes.order_number}}. The refund will be processed within 3-5 business days to your {{user.custom_attributes.payment_method|fallback:"original payment method"}}.\n\nIs there anything else I can help you with?', - created_at: "2025-07-21T14:44:35Z", - updated_at: "2025-07-21T14:44:35Z", - visible_to: "specific_teams", - visible_to_team_ids: ["support_team_1", "support_team_2"], - available_on: ["inbox", "messenger"], - }); - }); - - test("getMacro (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "macro", - id: "456", - name: "Product Demo Request", - body: '

Hello ,

Thank you for your interest in ! I\'d love to schedule a personalized demo for your team at .

Would work for you?

', - body_text: - 'Hello {{user.name|fallback:"valued customer"}},\n\nThank you for your interest in {{product.name|fallback:"our products"}}! I\'d love to schedule a personalized demo for your team at {{company.name|fallback:"your company"}}.\n\nWould {{suggested_time|fallback:"next Tuesday at 2 PM EST"}} work for you?', - created_at: "2025-07-22T11:06:40Z", - updated_at: "2025-07-23T00:00:00Z", - visible_to: "specific_teams", - visible_to_team_ids: ["sales_team_us", "sales_team_eu"], - available_on: ["messenger"], - }; - server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.getMacro({ - id: "123", - }); - expect(response).toEqual({ - type: "macro", - id: "456", - name: "Product Demo Request", - body: '

Hello ,

Thank you for your interest in ! I\'d love to schedule a personalized demo for your team at .

Would work for you?

', - body_text: - 'Hello {{user.name|fallback:"valued customer"}},\n\nThank you for your interest in {{product.name|fallback:"our products"}}! I\'d love to schedule a personalized demo for your team at {{company.name|fallback:"your company"}}.\n\nWould {{suggested_time|fallback:"next Tuesday at 2 PM EST"}} work for you?', - created_at: "2025-07-22T11:06:40Z", - updated_at: "2025-07-23T00:00:00Z", - visible_to: "specific_teams", - visible_to_team_ids: ["sales_team_us", "sales_team_eu"], - available_on: ["messenger"], - }); - }); - - test("getMacro (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "macro", - id: "890", - name: "API Integration Help", - body: '

Hi ,

I see you\'re having trouble with the integration. Your API key for app is configured correctly.

Error code:

Let me help you resolve this issue.

', - body_text: - 'Hi {{user.name}},\n\nI see you\'re having trouble with the {{conversation.custom_attributes.api_endpoint|fallback:"API"}} integration. Your API key for app {{app.id}} is configured correctly.\n\nError code: {{conversation.custom_attributes.error_code|fallback:"unknown"}}\n\nLet me help you resolve this issue.', - created_at: "2025-07-18T09:15:00Z", - updated_at: "2025-07-18T09:15:00Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }; - server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.getMacro({ - id: "123", - }); - expect(response).toEqual({ - type: "macro", - id: "890", - name: "API Integration Help", - body: '

Hi ,

I see you\'re having trouble with the integration. Your API key for app is configured correctly.

Error code:

Let me help you resolve this issue.

', - body_text: - 'Hi {{user.name}},\n\nI see you\'re having trouble with the {{conversation.custom_attributes.api_endpoint|fallback:"API"}} integration. Your API key for app {{app.id}} is configured correctly.\n\nError code: {{conversation.custom_attributes.error_code|fallback:"unknown"}}\n\nLet me help you resolve this issue.', - created_at: "2025-07-18T09:15:00Z", - updated_at: "2025-07-18T09:15:00Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox"], - }); - }); - - test("getMacro (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "macro", - id: "123", - name: "Thank You Response", - body: "

Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.

", - body_text: - "Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.", - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }; - server.mockEndpoint().get("/macros/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.macros.getMacro({ - id: "123", - }); - expect(response).toEqual({ - type: "macro", - id: "123", - name: "Thank You Response", - body: "

Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.

", - body_text: - "Thank you for reaching out! We appreciate your message and will get back to you as soon as possible.", - created_at: "2025-07-17T11:18:08Z", - updated_at: "2025-07-17T15:30:24Z", - visible_to: "everyone", - visible_to_team_ids: ["456", "789"], - available_on: ["inbox", "messenger"], - }); - }); - - test("getMacro (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/macros/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.getMacro({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getMacro (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/macros/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.getMacro({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("getMacro (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/macros/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.macros.getMacro({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/messages.test.ts b/tests/wire/unstable/messages.test.ts deleted file mode 100644 index 7b0b98a4..00000000 --- a/tests/wire/unstable/messages.test.ts +++ /dev/null @@ -1,766 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("MessagesClient", () => { - test("createMessage (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "user", id: "6762f2341bb69f9f2193bc17" }, - body: "heyy", - referer: "https://twitter.com/bob", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "user", - id: "6762f2341bb69f9f2193bc17", - }, - body: "heyy", - referer: "https://twitter.com/bob", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "lead", id: "6762f2371bb69f9f2193bc18" }, - body: "heyy", - referer: "https://twitter.com/bob", - }; - const rawResponseBody = { - type: "user_message", - id: "403918397", - created_at: 1734537783, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "614", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "lead", - id: "6762f2371bb69f9f2193bc18", - }, - body: "heyy", - referer: "https://twitter.com/bob", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918397", - created_at: 1734537783, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "614", - }); - }); - - test("createMessage (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "admin_message", - id: "19", - created_at: 1734537786, - subject: "heyy", - body: "heyy", - message_type: "inapp", - conversation_id: "64619700005570", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - type: "admin_message", - id: "19", - created_at: 1734537786, - subject: "heyy", - body: "heyy", - message_type: "inapp", - conversation_id: "64619700005570", - }); - }); - - test("createMessage (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267817" }, - to: { type: "user", id: "6762f23a1bb69f9f2193bc1a" }, - message_type: "sms", - body: "heyy", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "admin", - id: "991267817", - }, - to: { - type: "user", - id: "6762f23a1bb69f9f2193bc1a", - }, - message_type: "sms", - body: "heyy", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267817" }, - to: { phone: 5547999998888, name: "John Doe" }, - message_type: "whatsapp", - components: [{ type: "BODY", parameters: [{ type: "text", text: "Username 123" }] }], - template: "keep_live", - locale: "en", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "admin", - id: "991267817", - }, - to: { - phone: 5547999998888, - name: "John Doe", - }, - message_type: "whatsapp", - components: [ - { - type: "BODY", - parameters: [ - { - type: "text", - text: "Username 123", - }, - ], - }, - ], - template: "keep_live", - locale: "en", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267818" }, - to: { type: "user", id: "6762f23b1bb69f9f2193bc1a" }, - message_type: "inapp", - subject: "heyy", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "admin", - id: "991267818", - }, - to: { - type: "user", - id: "6762f23b1bb69f9f2193bc1a", - }, - message_type: "inapp", - subject: "heyy", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267819" }, - to: { type: "user", user_id: "70" }, - message_type: "email", - body: "hey there", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "admin", - id: "991267819", - }, - to: { - type: "user", - user_id: "70", - }, - message_type: "email", - body: "hey there", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (8)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267820" }, - to: { type: "user", id: "6762f23d1bb69f9f2193bc1c" }, - message_type: "email", - subject: "heyy", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.messages.createMessage({ - from: { - type: "admin", - id: "991267820", - }, - to: { - type: "user", - id: "6762f23d1bb69f9f2193bc1c", - }, - message_type: "email", - subject: "heyy", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (9)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - from: { type: "admin", id: "991267821" }, - to: { type: "user", id: "6762f23b1bb69f9f2193bc1d" }, - message_type: "sms", - body: "heyy https://picsum.photos/200/300", - }; - const rawResponseBody = { - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }; - server - .mockEndpoint() - .post("/messages") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - type: "user_message", - id: "403918396", - created_at: 1734537780, - subject: "Greetings", - body: "heyy", - message_type: "inapp", - conversation_id: "613", - }); - }); - - test("createMessage (10)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/messages").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createMessage (11)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/messages").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createMessage (12)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().post("/messages").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("createMessage (13)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().post("/messages").respondWith().statusCode(422).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.createMessage(undefined); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); - - test("getWhatsAppMessageStatus (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - ruleset_id: "ruleset_id", - pages: { type: "pages", per_page: 50, total_pages: 3, next: { starting_after: "abc123" } }, - total_count: 125, - events: [ - { - id: "event_1", - conversation_id: "conv_123", - status: "delivered", - type: "broadcast_outbound", - created_at: 1734537980, - updated_at: 1734538000, - whatsapp_message_id: "wamid_123", - template_name: "appointment_reminder", - }, - { - id: "event_2", - conversation_id: "conv_456", - status: "sent", - type: "broadcast_outbound", - created_at: 1734537970, - updated_at: 1734538010, - whatsapp_message_id: "wamid_456", - template_name: "order_update", - }, - ], - }; - server.mockEndpoint().get("/messages/status").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - per_page: 1, - starting_after: "starting_after", - }); - expect(response).toEqual({ - type: "list", - ruleset_id: "ruleset_id", - pages: { - type: "pages", - per_page: 50, - total_pages: 3, - next: { - starting_after: "abc123", - }, - }, - total_count: 125, - events: [ - { - id: "event_1", - conversation_id: "conv_123", - status: "delivered", - type: "broadcast_outbound", - created_at: 1734537980, - updated_at: 1734538000, - whatsapp_message_id: "wamid_123", - template_name: "appointment_reminder", - }, - { - id: "event_2", - conversation_id: "conv_456", - status: "sent", - type: "broadcast_outbound", - created_at: 1734537970, - updated_at: 1734538010, - whatsapp_message_id: "wamid_456", - template_name: "order_update", - }, - ], - }); - }); - - test("getWhatsAppMessageStatus (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/messages/status").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("getWhatsAppMessageStatus (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/messages/status").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getWhatsAppMessageStatus (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/messages/status").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("getWhatsAppMessageStatus (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/messages/status").respondWith().statusCode(500).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.messages.getWhatsAppMessageStatus({ - ruleset_id: "ruleset_id", - }); - }).rejects.toThrow(Intercom.unstable.InternalServerError); - }); -}); diff --git a/tests/wire/unstable/news.test.ts b/tests/wire/unstable/news.test.ts deleted file mode 100644 index 6ee5092f..00000000 --- a/tests/wire/unstable/news.test.ts +++ /dev/null @@ -1,864 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("NewsClient", () => { - test("listNewsItems (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }; - server.mockEndpoint().get("/news/news_items").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.news.listNewsItems(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }); - }); - - test("listNewsItems (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/news_items").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.news.listNewsItems(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createNewsItem (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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: ["😆", "😅"], - newsfeed_assignments: [{ newsfeed_id: 53, published_at: 1664638214 }], - }; - const rawResponseBody = { - type: "news-item", - id: "33", - workspace_id: "this_is_an_id534_that_should_be_at_least_", - title: "Halloween is here!", - body: "

New costumes in store for this spooky season

", - sender_id: 991267834, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 53, published_at: 1664638214 }], - labels: ["New", "Product", "Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😆", "😅"], - deliver_silently: true, - created_at: 1734537797, - updated_at: 1734537797, - }; - server - .mockEndpoint() - .post("/news/news_items") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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, - }, - ], - }); - expect(response).toEqual({ - type: "news-item", - id: "33", - workspace_id: "this_is_an_id534_that_should_be_at_least_", - title: "Halloween is here!", - body: "

New costumes in store for this spooky season

", - sender_id: 991267834, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 53, - published_at: 1664638214, - }, - ], - labels: ["New", "Product", "Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], - deliver_silently: true, - created_at: 1734537797, - updated_at: 1734537797, - }); - }); - - test("createNewsItem (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/news/news_items") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.createNewsItem({ - title: "title", - sender_id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveNewsItem (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "news-item", - id: "34", - workspace_id: "this_is_an_id538_that_should_be_at_least_", - title: "We have news", - body: "

Hello there,

", - sender_id: 991267837, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 55, published_at: 1734537800 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍", "👍", "👍", "👍"], - deliver_silently: false, - created_at: 1734537800, - updated_at: 1734537800, - }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.news.retrieveNewsItem({ - id: 1, - }); - expect(response).toEqual({ - type: "news-item", - id: "34", - workspace_id: "this_is_an_id538_that_should_be_at_least_", - title: "We have news", - body: "

Hello there,

", - sender_id: 991267837, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 55, - published_at: 1734537800, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D", "\uD83D\uDC4D", "\uD83D\uDC4D", "\uD83D\uDC4D"], - deliver_silently: false, - created_at: 1734537800, - updated_at: 1734537800, - }); - }); - - test("retrieveNewsItem (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.news.retrieveNewsItem({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveNewsItem (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/news/news_items/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.news.retrieveNewsItem({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateNewsItem (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - reactions: ["😝", "😂"], - }; - const rawResponseBody = { - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😝", "😂"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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"], - }, - }); - expect(response).toEqual({ - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }); - }); - - test("updateNewsItem (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267848, - reactions: ["😝", "😂"], - }; - const rawResponseBody = { - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["😝", "😂"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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"], - }, - }); - expect(response).toEqual({ - type: "news-item", - id: "37", - workspace_id: "this_is_an_id544_that_should_be_at_least_", - title: "Christmas is here!", - body: "

New gifts in store for the jolly season

", - sender_id: 991267845, - state: "live", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], - deliver_silently: false, - created_at: 1734537803, - updated_at: 1734537804, - }); - }); - - test("updateNewsItem (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.updateNewsItem({ - id: 1, - body: { - title: "title", - sender_id: 1, - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateNewsItem (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { title: "title", sender_id: 1 }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/news/news_items/1") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.updateNewsItem({ - id: 1, - body: { - title: "title", - sender_id: 1, - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteNewsItem (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "40", object: "news-item", deleted: true }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.news.deleteNewsItem({ - id: 1, - }); - expect(response).toEqual({ - id: "40", - object: "news-item", - deleted: true, - }); - }); - - test("deleteNewsItem (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.deleteNewsItem({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteNewsItem (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/news/news_items/1") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.deleteNewsItem({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listLiveNewsfeedItems (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 20, - total_pages: 0, - }, - total_count: 0, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [{ newsfeed_id: 198313, published_at: 1674917488 }], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["👍"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }; - server - .mockEndpoint() - .get("/news/newsfeeds/123/items") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.news.listLiveNewsfeedItems({ - id: "123", - }); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 20, - total_pages: 0, - }, - total_count: 0, - data: [ - { - type: "news-item", - id: "141", - workspace_id: "t74hdn32", - title: "New feature: News Items", - body: "We are excited to announce the launch of News Items, a new content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers.", - sender_id: 123, - state: "draft", - newsfeed_assignments: [ - { - newsfeed_id: 198313, - published_at: 1674917488, - }, - ], - labels: ["Product Update"], - cover_image_url: "https://example.com/cover.jpg", - reactions: ["\uD83D\uDC4D"], - deliver_silently: true, - created_at: 1610589632, - updated_at: 1610589632, - }, - ], - }); - }); - - test("listLiveNewsfeedItems (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/news/newsfeeds/id/items") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.news.listLiveNewsfeedItems({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("listNewsfeeds (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { type: "newsfeed", id: "12312", name: "My Newsfeed", created_at: 1674917488, updated_at: 1674917488 }, - { type: "newsfeed", id: "12312", name: "My Newsfeed", created_at: 1674917488, updated_at: 1674917488 }, - ], - }; - server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.news.listNewsfeeds(); - expect(response).toEqual({ - type: "list", - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 10, - total_pages: 1, - }, - total_count: 2, - data: [ - { - id: "12312", - type: "newsfeed", - name: "My Newsfeed", - created_at: 1674917488, - updated_at: 1674917488, - }, - { - id: "12312", - type: "newsfeed", - name: "My Newsfeed", - created_at: 1674917488, - updated_at: 1674917488, - }, - ], - }); - }); - - test("listNewsfeeds (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/newsfeeds").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.news.listNewsfeeds(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveNewsfeed (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - id: "72", - type: "newsfeed", - name: "Visitor Feed", - created_at: 1734537815, - updated_at: 1734537815, - }; - server - .mockEndpoint() - .get("/news/newsfeeds/123") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.news.retrieveNewsfeed({ - id: "123", - }); - expect(response).toEqual({ - id: "72", - type: "newsfeed", - name: "Visitor Feed", - created_at: 1734537815, - updated_at: 1734537815, - }); - }); - - test("retrieveNewsfeed (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/news/newsfeeds/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.news.retrieveNewsfeed({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/notes.test.ts b/tests/wire/unstable/notes.test.ts deleted file mode 100644 index 64bff186..00000000 --- a/tests/wire/unstable/notes.test.ts +++ /dev/null @@ -1,763 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("NotesClient", () => { - test("listCompanyNotes (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "note", - id: "26", - created_at: 1733932587, - contact: { id: "214656d0c743eafcfde7f248" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "25", - created_at: 1733846187, - contact: { id: "214656d0c743eafcfde7f248" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "24", - created_at: 1733846187, - contact: { id: "214656d0c743eafcfde7f248" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

This is a note.

", - }, - ], - total_count: 3, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 50, - total_pages: 1, - }, - }; - server - .mockEndpoint() - .get("/companies/5f4d3c1c-7b1b-4d7d-a97e-6095715c6632/notes") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.notes.listCompanyNotes({ - id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "note", - id: "26", - created_at: 1733932587, - contact: { - id: "214656d0c743eafcfde7f248", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "25", - created_at: 1733846187, - contact: { - id: "214656d0c743eafcfde7f248", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "24", - created_at: 1733846187, - contact: { - id: "214656d0c743eafcfde7f248", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

This is a note.

", - }, - ], - total_count: 3, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 50, - total_pages: 1, - }, - }); - }); - - test("listCompanyNotes (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/companies/id/notes") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.notes.listCompanyNotes({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listNotes (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "note", - id: "26", - created_at: 1733932587, - contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "25", - created_at: 1733846187, - contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "24", - created_at: 1733846187, - contact: { type: "contact", id: "6762f0ab1bb69f9f2193bb60" }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - ], - total_count: 3, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 50, - total_pages: 1, - }, - }; - server.mockEndpoint().get("/contacts/1/notes").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.notes.listNotes({ - id: 1, - }); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "note", - id: "26", - created_at: 1733932587, - contact: { - type: "contact", - id: "6762f0ab1bb69f9f2193bb60", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "25", - created_at: 1733846187, - contact: { - type: "contact", - id: "6762f0ab1bb69f9f2193bb60", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - { - type: "note", - id: "24", - created_at: 1733846187, - contact: { - type: "contact", - id: "6762f0ab1bb69f9f2193bb60", - }, - author: { - type: "admin", - id: "991267581", - name: "Ciaran122 Lee", - email: "admin122@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - }, - body: "

This is a note.

", - }, - ], - total_count: 3, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 50, - total_pages: 1, - }, - }); - }); - - test("listNotes (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/contacts/1/notes").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.notes.listNotes({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("createNote (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", contact_id: "6762f0ad1bb69f9f2193bb62", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/1/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.notes.createNote({ - id: 1, - body: "Hello", - contact_id: "6762f0ad1bb69f9f2193bb62", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("createNote (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", contact_id: "6762f0af1bb69f9f2193bb63", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/1/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.notes.createNote({ - id: 1, - body: "Hello", - contact_id: "6762f0af1bb69f9f2193bb63", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("createNote (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "Hello", contact_id: "123", admin_id: "123" }; - const rawResponseBody = { - type: "note", - id: "31", - created_at: 1734537390, - contact: { type: "contact", id: "6762f0ad1bb69f9f2193bb62" }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

Hello

", - }; - server - .mockEndpoint() - .post("/contacts/1/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.notes.createNote({ - id: 1, - body: "Hello", - contact_id: "123", - admin_id: "123", - }); - expect(response).toEqual({ - type: "note", - id: "31", - created_at: 1734537390, - contact: { - type: "contact", - id: "6762f0ad1bb69f9f2193bb62", - }, - author: { - type: "admin", - id: "991267583", - name: "Ciaran124 Lee", - email: "admin124@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

Hello

", - }); - }); - - test("createNote (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { body: "body" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/1/notes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.notes.createNote({ - id: 1, - body: "body", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("retrieveNote (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "note", - id: "34", - created_at: 1733846617, - contact: { type: "contact", id: "6762f2591bb69f9f2193bc1f" }, - author: { - type: "admin", - id: "991267864", - name: "Ciaran346 Lee", - email: "admin346@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { primary_team_ids: [814865], secondary_team_ids: [493881] }, - }, - body: "

This is a note.

", - }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.notes.retrieveNote({ - id: 1, - }); - expect(response).toEqual({ - type: "note", - id: "34", - created_at: 1733846617, - contact: { - type: "contact", - id: "6762f2591bb69f9f2193bc1f", - }, - author: { - type: "admin", - id: "991267864", - name: "Ciaran346 Lee", - email: "admin346@email.com", - job_title: "Associate", - away_mode_enabled: false, - away_mode_reassign: false, - away_status_reason_id: 12345, - has_inbox_seat: true, - team_ids: [814865], - avatar: "https://picsum.photos/200/300", - team_priority_level: { - primary_team_ids: [814865], - secondary_team_ids: [493881], - }, - }, - body: "

This is a note.

", - }); - }); - - test("retrieveNote (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.notes.retrieveNote({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveNote (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/notes/1").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.notes.retrieveNote({ - id: 1, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/segments.test.ts b/tests/wire/unstable/segments.test.ts deleted file mode 100644 index 71d84bae..00000000 --- a/tests/wire/unstable/segments.test.ts +++ /dev/null @@ -1,162 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("SegmentsClient", () => { - test("listSegments (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "segment.list", - segments: [ - { - type: "segment", - id: "6762f25c1bb69f9f2193bc22", - name: "John segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - { - type: "segment", - id: "6762f25c1bb69f9f2193bc23", - name: "Jane segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - ], - pages: { key: "value" }, - }; - server.mockEndpoint().get("/segments").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.segments.listSegments({ - include_count: true, - }); - expect(response).toEqual({ - type: "segment.list", - segments: [ - { - type: "segment", - id: "6762f25c1bb69f9f2193bc22", - name: "John segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - { - type: "segment", - id: "6762f25c1bb69f9f2193bc23", - name: "Jane segment", - created_at: 1734537820, - updated_at: 1734537820, - person_type: "user", - count: 3, - }, - ], - pages: { - key: "value", - }, - }); - }); - - test("listSegments (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/segments").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.segments.listSegments(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveSegment (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "segment", - id: "6762f25f1bb69f9f2193bc26", - name: "John segment", - created_at: 1734537823, - updated_at: 1734537823, - person_type: "user", - count: 3, - }; - server.mockEndpoint().get("/segments/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.segments.retrieveSegment({ - id: "123", - }); - expect(response).toEqual({ - type: "segment", - id: "6762f25f1bb69f9f2193bc26", - name: "John segment", - created_at: 1734537823, - updated_at: 1734537823, - person_type: "user", - count: 3, - }); - }); - - test("retrieveSegment (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/segments/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.segments.retrieveSegment({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveSegment (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/segments/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.segments.retrieveSegment({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/subscriptionTypes.test.ts b/tests/wire/unstable/subscriptionTypes.test.ts deleted file mode 100644 index 56304a5e..00000000 --- a/tests/wire/unstable/subscriptionTypes.test.ts +++ /dev/null @@ -1,410 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("SubscriptionTypesClient", () => { - test("attachSubscriptionTypeToContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "37846", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscriptionTypeToContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "37846", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscriptionTypeToContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "invalid_id", consent_type: "opt_in" }; - const rawResponseBody = { - type: "subscription", - id: "106", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "invalid_id", - consent_type: "opt_in", - }); - expect(response).toEqual({ - type: "subscription", - id: "106", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("attachSubscriptionTypeToContact (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", consent_type: "consent_type" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/contact_id/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "contact_id", - id: "id", - consent_type: "consent_type", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachSubscriptionTypeToContact (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", consent_type: "consent_type" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/subscriptions") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ - contact_id: "contact_id", - id: "id", - consent_type: "consent_type", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachSubscriptionTypeToContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "subscription", - id: "122", - state: "live", - default_translation: { name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_in", - content_types: ["sms_message"], - }; - server - .mockEndpoint() - .delete("/contacts/63a07ddf05a32042dffac965/subscriptions/37846") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "37846", - }); - expect(response).toEqual({ - type: "subscription", - id: "122", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_in", - content_types: ["sms_message"], - }); - }); - - test("detachSubscriptionTypeToContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/subscriptions/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachSubscriptionTypeToContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/subscriptions/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listSubscriptionTypes (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "subscription", - id: "135", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [{ name: "Newsletters", description: "Lorem ipsum dolor sit amet", locale: "en" }], - consent_type: "opt_out", - content_types: ["email"], - }, - ], - }; - server - .mockEndpoint() - .get("/subscription_types") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.subscriptionTypes.listSubscriptionTypes(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "subscription", - id: "135", - state: "live", - default_translation: { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - translations: [ - { - name: "Newsletters", - description: "Lorem ipsum dolor sit amet", - locale: "en", - }, - ], - consent_type: "opt_out", - content_types: ["email"], - }, - ], - }); - }); - - test("listSubscriptionTypes (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/subscription_types") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.subscriptionTypes.listSubscriptionTypes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/switch.test.ts b/tests/wire/unstable/switch.test.ts deleted file mode 100644 index d7ee5321..00000000 --- a/tests/wire/unstable/switch.test.ts +++ /dev/null @@ -1,113 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("SwitchClient", () => { - test("createPhoneSwitch (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "phone_call_redirect", phone: "phone" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.switch.createPhoneSwitch({ - key: "value", - }); - expect(response).toEqual({ - type: "phone_call_redirect", - phone: "phone", - }); - }); - - test("createPhoneSwitch (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createPhoneSwitch (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createPhoneSwitch (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/phone_call_redirects") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(422) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.switch.createPhoneSwitch({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnprocessableEntityError); - }); -}); diff --git a/tests/wire/unstable/tags.test.ts b/tests/wire/unstable/tags.test.ts deleted file mode 100644 index e7094ebe..00000000 --- a/tests/wire/unstable/tags.test.ts +++ /dev/null @@ -1,1371 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TagsClient", () => { - test("attachTagToContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "123" }; - const rawResponseBody = { - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/contacts/63a07ddf05a32042dffac965/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "81", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToContact (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/contacts/contact_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachTagToContact (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/contacts/contact_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachTagFromContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "tag", - id: "84", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/contacts/63a07ddf05a32042dffac965/tags/7522907") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromContact({ - contact_id: "63a07ddf05a32042dffac965", - id: "7522907", - }); - expect(response).toEqual({ - type: "tag", - id: "84", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/contacts/contact_id/tags/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachTagFromContact (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/contacts/contact_id/tags/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromContact({ - contact_id: "contact_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("attachTagToConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/conversations/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/conversations/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "86", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/conversations/conversation_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachTagToConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/conversations/conversation_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachTagFromConversation (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromConversation (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromConversation (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/conversations/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromConversation({ - conversation_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "89", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromConversation (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/tags/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachTagFromConversation (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/conversations/conversation_id/tags/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromConversation({ - conversation_id: "conversation_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("listTags (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "tag", - id: "102", - name: "Manual tag 1", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }, - ], - }; - server.mockEndpoint().get("/tags").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.tags.listTags(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "tag", - id: "102", - name: "Manual tag 1", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }, - ], - }); - }); - - test("listTags (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tags").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.listTags(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createTag (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "test", - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "Independent" }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "Independent", - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", companies: [{ company_id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "test", - companies: [ - { - company_id: "123", - }, - ], - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "test", users: [{ id: "123" }] }; - const rawResponseBody = { - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.createTag({ - name: "test", - users: [ - { - id: "123", - }, - ], - }); - expect(response).toEqual({ - type: "tag", - id: "105", - name: "test", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("createTag (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.createTag({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("createTag (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.createTag({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createTag (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.createTag({ - name: "name", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("findTag (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server.mockEndpoint().get("/tags/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.tags.findTag({ - id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "113", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("findTag (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tags/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.findTag({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("findTag (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/tags/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.findTag({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteTag (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - server.mockEndpoint().delete("/tags/123").respondWith().statusCode(200).build(); - - const response = await client.unstable.tags.deleteTag({ - id: "123", - }); - expect(response).toEqual(undefined); - }); - - test("deleteTag (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tags/id").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.deleteTag({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("deleteTag (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/tags/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.deleteTag({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteTag (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tags/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tags.deleteTag({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("attachTagToTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tickets/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "7522907", admin_id: "780" }; - const rawResponseBody = { - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .post("/tickets/64619700005694/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.attachTagToTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "780", - }); - expect(response).toEqual({ - type: "tag", - id: "121", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("attachTagToTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/ticket_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("attachTagToTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id", admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/ticket_id/tags") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.attachTagToTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("detachTagFromTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "123" }; - const rawResponseBody = { - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { type: "contact", id: "1a2b3c" }, - }; - server - .mockEndpoint() - .delete("/tickets/64619700005694/tags/7522907") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tags.detachTagFromTicket({ - ticket_id: "64619700005694", - id: "7522907", - admin_id: "123", - }); - expect(response).toEqual({ - type: "tag", - id: "124", - name: "Manual tag", - applied_at: 1663597223, - applied_by: { - type: "contact", - id: "1a2b3c", - }, - }); - }); - - test("detachTagFromTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .delete("/tickets/ticket_id/tags/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("detachTagFromTicket (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { admin_id: "admin_id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .delete("/tickets/ticket_id/tags/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tags.detachTagFromTicket({ - ticket_id: "ticket_id", - id: "id", - admin_id: "admin_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/teams.test.ts b/tests/wire/unstable/teams.test.ts deleted file mode 100644 index f25b2268..00000000 --- a/tests/wire/unstable/teams.test.ts +++ /dev/null @@ -1,136 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TeamsClient", () => { - test("listTeams (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "team.list", - teams: [ - { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, - }, - ], - }; - server.mockEndpoint().get("/teams").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.teams.listTeams(); - expect(response).toEqual({ - type: "team.list", - teams: [ - { - type: "team", - id: "814865", - name: "Example Team", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, - }, - ], - }); - }); - - test("listTeams (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.teams.listTeams(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveTeam (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "team", - id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { primary_admin_ids: [493881], secondary_admin_ids: [814865] }, - }; - server.mockEndpoint().get("/teams/123").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.teams.retrieveTeam({ - id: "123", - }); - expect(response).toEqual({ - type: "team", - id: "991267902", - name: "team 1", - admin_ids: [493881], - admin_priority_level: { - primary_admin_ids: [493881], - secondary_admin_ids: [814865], - }, - }); - }); - - test("retrieveTeam (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/teams/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.teams.retrieveTeam({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveTeam (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/teams/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.teams.retrieveTeam({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/unstable/ticketStates.test.ts b/tests/wire/unstable/ticketStates.test.ts deleted file mode 100644 index 21e2b43c..00000000 --- a/tests/wire/unstable/ticketStates.test.ts +++ /dev/null @@ -1,504 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TicketStatesClient", () => { - test("listTicketStates (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "ticket_state", - id: "8269", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8270", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8271", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8272", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8273", - category: "submitted", - internal_label: "Admin label 1", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8274", - category: "submitted", - internal_label: "Admin label 2", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - ], - }; - server.mockEndpoint().get("/ticket_states").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.ticketStates.listTicketStates(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "ticket_state", - id: "8269", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8270", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8271", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8272", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8273", - category: "submitted", - internal_label: "Admin label 1", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "55", - category: "Back-office", - name: "my-ticket-type-3", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - { - type: "ticket_type", - id: "56", - category: "Back-office", - name: "my-ticket-type-4", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - { - type: "ticket_state", - id: "8274", - category: "submitted", - internal_label: "Admin label 2", - external_label: "User label", - archived: false, - ticket_types: { - type: "list", - data: [ - { - type: "ticket_type", - id: "58", - category: "Back-office", - name: "my-ticket-type-6", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "ecahpwf5", - archived: false, - }, - ], - }, - }, - ], - }); - }); - - test("listTicketStates (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ticket_states").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.ticketStates.listTicketStates(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/ticketTypeAttributes.test.ts b/tests/wire/unstable/ticketTypeAttributes.test.ts deleted file mode 100644 index 83b633bd..00000000 --- a/tests/wire/unstable/ticketTypeAttributes.test.ts +++ /dev/null @@ -1,200 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TicketTypeAttributesClient", () => { - test("createTicketTypeAttribute (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false, - }; - const rawResponseBody = { - type: "ticket_type_attribute", - id: "157", - workspace_id: "this_is_an_id640_that_should_be_at_least_", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - input_options: { multiline: false }, - order: 2, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: true, - visible_to_contacts: true, - default: false, - ticket_type_id: 63, - archived: false, - created_at: 1734537862, - updated_at: 1734537862, - }; - server - .mockEndpoint() - .post("/ticket_types/ticket_type_id/attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - required_to_create: false, - }); - expect(response).toEqual({ - type: "ticket_type_attribute", - id: "157", - workspace_id: "this_is_an_id640_that_should_be_at_least_", - name: "Attribute Title", - description: "Attribute Description", - data_type: "string", - input_options: { - multiline: false, - }, - order: 2, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: true, - visible_to_contacts: true, - default: false, - ticket_type_id: 63, - archived: false, - created_at: 1734537862, - updated_at: 1734537862, - }); - }); - - test("createTicketTypeAttribute (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { name: "name", description: "description", data_type: "string" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ticket_types/ticket_type_id/attributes") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - name: "name", - description: "description", - data_type: "string", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateTicketTypeAttribute (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { description: "New Attribute Description" }; - const rawResponseBody = { - type: "ticket_type_attribute", - id: "162", - workspace_id: "this_is_an_id644_that_should_be_at_least_", - name: "name", - description: "New Attribute Description", - data_type: "string", - input_options: { key: "value" }, - order: 0, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: false, - ticket_type_id: 65, - archived: false, - created_at: 1734537864, - updated_at: 1734537864, - }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id/attributes/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - id: "id", - description: "New Attribute Description", - }); - expect(response).toEqual({ - type: "ticket_type_attribute", - id: "162", - workspace_id: "this_is_an_id644_that_should_be_at_least_", - name: "name", - description: "New Attribute Description", - data_type: "string", - input_options: { - key: "value", - }, - order: 0, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: false, - ticket_type_id: 65, - archived: false, - created_at: 1734537864, - updated_at: 1734537864, - }); - }); - - test("updateTicketTypeAttribute (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/ticket_types/ticket_type_id/attributes/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ - ticket_type_id: "ticket_type_id", - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/ticketTypes.test.ts b/tests/wire/unstable/ticketTypes.test.ts deleted file mode 100644 index 95efe063..00000000 --- a/tests/wire/unstable/ticketTypes.test.ts +++ /dev/null @@ -1,518 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TicketTypesClient", () => { - test("listTicketTypes (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "list", - data: [ - { - type: "ticket_type", - id: "67", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id648_that_should_be_at_least_", - ticket_type_attributes: { type: "list" }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8321", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8322", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8323", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8324", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537866, - updated_at: 1734537866, - }, - ], - }; - server.mockEndpoint().get("/ticket_types").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.ticketTypes.listTicketTypes(); - expect(response).toEqual({ - type: "list", - data: [ - { - type: "ticket_type", - id: "67", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id648_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8321", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8322", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8323", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8324", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537866, - updated_at: 1734537866, - }, - ], - }); - }); - - test("listTicketTypes (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ticket_types").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.ticketTypes.listTicketTypes(); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("createTicketType (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { - type: "type", - id: "id", - category: "Customer", - name: "name", - description: "description", - icon: "icon", - workspace_id: "workspace_id", - ticket_type_attributes: { - type: "type", - ticket_type_attributes: [ - { - type: "type", - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - data_type: "data_type", - input_options: { input_options: { key: "value" } }, - order: 1, - required_to_create: true, - required_to_create_for_contacts: true, - visible_on_create: true, - visible_to_contacts: true, - default: true, - ticket_type_id: 1, - archived: true, - created_at: 1, - updated_at: 1, - }, - { - type: "type", - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - data_type: "data_type", - input_options: { input_options: { key: "value" } }, - order: 1, - required_to_create: true, - required_to_create_for_contacts: true, - visible_on_create: true, - visible_to_contacts: true, - default: true, - ticket_type_id: 1, - archived: true, - created_at: 1, - updated_at: 1, - }, - ], - }, - ticket_states: { - type: "type", - data: [ - { - type: "type", - id: "id", - category: "submitted", - internal_label: "internal_label", - external_label: "external_label", - }, - { - type: "type", - id: "id", - category: "submitted", - internal_label: "internal_label", - external_label: "external_label", - }, - ], - }, - archived: true, - created_at: 1, - updated_at: 1, - }; - server - .mockEndpoint() - .post("/ticket_types") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.ticketTypes.createTicketType({ - key: "value", - }); - expect(response).toEqual({ - type: "type", - id: "id", - category: "Customer", - name: "name", - description: "description", - icon: "icon", - workspace_id: "workspace_id", - ticket_type_attributes: { - type: "type", - ticket_type_attributes: [ - { - type: "type", - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - data_type: "data_type", - input_options: { - input_options: { - key: "value", - }, - }, - order: 1, - required_to_create: true, - required_to_create_for_contacts: true, - visible_on_create: true, - visible_to_contacts: true, - default: true, - ticket_type_id: 1, - archived: true, - created_at: 1, - updated_at: 1, - }, - { - type: "type", - id: "id", - workspace_id: "workspace_id", - name: "name", - description: "description", - data_type: "data_type", - input_options: { - input_options: { - key: "value", - }, - }, - order: 1, - required_to_create: true, - required_to_create_for_contacts: true, - visible_on_create: true, - visible_to_contacts: true, - default: true, - ticket_type_id: 1, - archived: true, - created_at: 1, - updated_at: 1, - }, - ], - }, - ticket_states: { - type: "type", - data: [ - { - type: "type", - id: "id", - category: "submitted", - internal_label: "internal_label", - external_label: "external_label", - }, - { - type: "type", - id: "id", - category: "submitted", - internal_label: "internal_label", - external_label: "external_label", - }, - ], - }, - archived: true, - created_at: 1, - updated_at: 1, - }); - }); - - test("createTicketType (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/ticket_types") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.ticketTypes.createTicketType({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getTicketType (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "ticket_type", - id: "72", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "🎟️", - workspace_id: "this_is_an_id656_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - data_type: "string", - input_options: { key: "value" }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8353", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8354", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8355", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8356", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537870, - updated_at: 1734537870, - }; - server.mockEndpoint().get("/ticket_types/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.ticketTypes.getTicketType({ - id: "id", - }); - expect(response).toEqual({ - type: "ticket_type", - id: "72", - category: "Customer", - name: "Bug Report", - description: "Bug Report Template", - icon: "\uD83C\uDF9F\uFE0F", - workspace_id: "this_is_an_id656_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [ - { - type: "ticket_type_attribute", - id: "1", - workspace_id: "ecahpwf5", - name: "Title", - description: "Bug title.", - data_type: "string", - input_options: { - key: "value", - }, - order: 1, - required_to_create: false, - required_to_create_for_contacts: false, - visible_on_create: false, - visible_to_contacts: false, - default: true, - ticket_type_id: 42, - archived: false, - }, - ], - }, - ticket_states: { - type: "list", - data: [ - { - type: "ticket_state", - id: "8353", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - { - type: "ticket_state", - id: "8354", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - { - type: "ticket_state", - id: "8355", - category: "waiting_on_customer", - internal_label: "Waiting on customer", - external_label: "Waiting on you", - }, - { - type: "ticket_state", - id: "8356", - category: "resolved", - internal_label: "Resolved", - external_label: "Resolved", - }, - ], - }, - archived: false, - created_at: 1734537870, - updated_at: 1734537870, - }); - }); - - test("getTicketType (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/ticket_types/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.ticketTypes.getTicketType({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/tickets.test.ts b/tests/wire/unstable/tickets.test.ts deleted file mode 100644 index d1c30b68..00000000 --- a/tests/wire/unstable/tickets.test.ts +++ /dev/null @@ -1,3265 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("TicketsClient", () => { - test("replyTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tickets.replyTicket({ - id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2971bb69f9f2193bc49", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("replyTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("replyTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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" }, - ], - }; - const rawResponseBody = { - type: "ticket_part", - id: "158", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537890, - updated_at: 1734537890, - author: { type: "admin", id: "991267948", name: "Ciaran423 Lee", email: "admin423@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }, - ], - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "158", - part_type: "quick_reply", - body: "

Okay!

", - created_at: 1734537890, - updated_at: 1734537890, - author: { - type: "admin", - id: "991267948", - name: "Ciaran423 Lee", - email: "admin423@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("replyTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2a41bb69f9f2193bc4c", - }; - const rawResponseBody = { - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { type: "admin", id: "991267943", name: "Ciaran419 Lee", email: "admin419@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }; - server - .mockEndpoint() - .post("/tickets/123/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tickets.replyTicket({ - id: "123", - body: { - message_type: "comment", - type: "user", - body: "Thanks again :)", - intercom_user_id: "6762f2a41bb69f9f2193bc4c", - }, - }); - expect(response).toEqual({ - type: "ticket_part", - id: "156", - part_type: "note", - body: "

An Unordered HTML List

\n
    \n
  • Coffee
  • \n
  • Tea
  • \n
  • Milk
  • \n
\n

An Ordered HTML List

\n
    \n
  1. Coffee
  2. \n
  3. Tea
  4. \n
  5. Milk
  6. \n
", - created_at: 1734537884, - updated_at: 1734537884, - author: { - type: "admin", - id: "991267943", - name: "Ciaran419 Lee", - email: "admin419@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - redacted: false, - }); - }); - - test("replyTicket (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.replyTicket({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("replyTicket (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.replyTicket({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("replyTicket (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/id/reply") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.replyTicket({ - id: "id", - body: { - intercom_user_id: "intercom_user_id", - message_type: "comment", - type: "user", - body: "body", - }, - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("enqueueCreateTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "1234", contacts: [{ id: "6762f2d81bb69f9f2193bc54" }] }; - const rawResponseBody = { - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", - }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "1234", - contacts: [ - { - id: "6762f2d81bb69f9f2193bc54", - }, - ], - }); - expect(response).toEqual({ - type: "job", - id: "20", - url: "https://api.intercom.io/jobs/status/20", - status: "pending", - resource_type: "ticket", - resource_id: "resource_id", - resource_url: "http://api.intercom.io/tickets/123", - }); - }); - - test("enqueueCreateTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("enqueueCreateTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_type_id: "ticket_type_id", contacts: [{ id: "id" }, { id: "id" }] }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/tickets/enqueue") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.enqueueCreateTicket({ - ticket_type_id: "ticket_type_id", - contacts: [ - { - id: "id", - }, - { - id: "id", - }, - ], - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("getTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { _default_title_: "attribute_value", _default_description_: "ticket_attributes" }, - ticket_state: { - type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "95", - category: "Back-office", - name: "my-ticket-type-30", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id702_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537973, - updated_at: 1734537973, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, - author: { type: "admin", id: "991268047", name: "Ciaran509 Lee", email: "admin509@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }; - server.mockEndpoint().get("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.tickets.getTicket({ - id: "id", - }); - expect(response).toEqual({ - type: "ticket", - id: "631", - ticket_id: "38", - category: "Back-office", - ticket_attributes: { - _default_title_: "attribute_value", - _default_description_: "ticket_attributes", - }, - ticket_state: { - type: "ticket_state", - id: "8537", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "95", - category: "Back-office", - name: "my-ticket-type-30", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id702_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537973, - updated_at: 1734537973, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2f61bb69f9f2193bc59", - external_id: "b16afa36-2637-4880-adee-a46d145bc27f", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537974, - updated_at: 1734537976, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "185", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537975, - updated_at: 1734537975, - author: { - type: "admin", - id: "991268047", - name: "Ciaran509 Lee", - email: "admin509@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }); - }); - - test("getTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.getTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - 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", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("updateTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("updateTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state_id: "123", - admin_id: 991268011, - assignee_id: "123", - }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = 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", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("updateTicket (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { ticket_state_id: "123" }; - const rawResponseBody = { - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { _default_title_: "example", _default_description_: "there is a problem" }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { type: "list", ticket_type_attributes: [] }, - ticket_states: { type: "list", data: [] }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "10", label: "Photo" }, - value: { type: "value", id: [2], label: ["photo.png"] }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { type: "attribute", id: "7", label: "Progress" }, - value: { type: "value", id: "Fast", label: "Fast" }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { type: "admin", id: "991268013" }, - author: { type: "admin", id: "991268011", name: "Ciaran477 Lee", email: "admin477@email.com" }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tickets.updateTicket({ - id: "id", - ticket_state_id: "123", - }); - expect(response).toEqual({ - type: "ticket", - id: "627", - ticket_id: "34", - category: "Back-office", - ticket_attributes: { - _default_title_: "example", - _default_description_: "there is a problem", - }, - ticket_state: { - type: "ticket_state", - id: "8498", - category: "in_progress", - internal_label: "In progress", - external_label: "In progress", - }, - ticket_type: { - type: "ticket_type", - id: "90", - category: "Back-office", - name: "my-ticket-type-25", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id692_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - ticket_type_attributes: [], - }, - ticket_states: { - type: "list", - data: [], - }, - archived: false, - created_at: 1734537948, - updated_at: 1734537948, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f2dd1bb69f9f2193bc55", - external_id: "8df1fa21-b41d-4621-9229-d6f7a3a590ce", - }, - ], - }, - admin_assignee_id: "991268013", - team_assignee_id: "0", - created_at: 1734537950, - updated_at: 1734537955, - open: true, - snoozed_until: 1734627600, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "176", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537951, - updated_at: 1734537951, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "177", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "10", - label: "Photo", - }, - value: { - type: "value", - id: [2], - label: ["photo.png"], - }, - }, - }, - { - type: "ticket_part", - id: "178", - part_type: "ticket_attribute_updated_by_admin", - body: "

Okay!

", - created_at: 1734537953, - updated_at: 1734537953, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - updated_attribute_data: { - attribute: { - type: "attribute", - id: "7", - label: "Progress", - }, - value: { - type: "value", - id: "Fast", - label: "Fast", - }, - }, - }, - { - type: "ticket_part", - id: "179", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "in_progress", - created_at: 1734537954, - updated_at: 1734537954, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "test-integration", - }, - { - type: "ticket_part", - id: "180", - part_type: "assignment", - body: "

Okay!

", - created_at: 1734537954, - updated_at: 1734537954, - assigned_to: { - type: "admin", - id: "991268013", - }, - author: { - type: "admin", - id: "991268011", - name: "Ciaran477 Lee", - email: "admin477@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - { - type: "ticket_part", - id: "181", - part_type: "snoozed", - body: "

Okay!

", - created_at: 1734537955, - updated_at: 1734537955, - author: { - type: "bot", - id: "991268012", - name: "Fin", - email: "operator+this_is_an_id692_that_should_be_at_least_@intercom.io", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 6, - }, - is_shared: false, - }); - }); - - test("updateTicket (5)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.BadRequestError); - }); - - test("updateTicket (6)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateTicket (7)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/tickets/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.tickets.updateTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("deleteTicket (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { id: "632", object: "ticket", deleted: true }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.tickets.deleteTicket({ - id: "id", - }); - expect(response).toEqual({ - id: "632", - object: "ticket", - deleted: true, - }); - }); - - test("deleteTicket (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.deleteTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("deleteTicket (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().delete("/tickets/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.tickets.deleteTicket({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("searchTickets", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - query: { operator: "AND", value: [{ field: "created_at", operator: ">", value: "1306054154" }] }, - pagination: { per_page: 5 }, - }; - const rawResponseBody = { - type: "ticket.list", - tickets: [ - { - type: "ticket", - id: "633", - ticket_id: "40", - category: "Back-office", - ticket_attributes: { _default_title_: "attribute_value", _default_description_: undefined }, - ticket_state: { - type: "ticket_state", - id: "8577", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "100", - category: "Back-office", - name: "my-ticket-type-35", - description: "my ticket type description is awesome.", - icon: "🦁", - workspace_id: "this_is_an_id712_that_should_be_at_least_", - ticket_type_attributes: { type: "list" }, - archived: false, - created_at: 1734537989, - updated_at: 1734537989, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f3061bb69f9f2193bc5b", - external_id: "9b913927-c084-4391-b1db-098341b5ffe3", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537990, - updated_at: 1734537992, - open: true, - snoozed_until: 1663597260, - linked_objects: { type: "list", total_count: 0, has_more: false, data: [{ id: "7583" }] }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "188", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537991, - updated_at: 1734537991, - author: { - type: "admin", - id: "991268079", - name: "Ciaran539 Lee", - email: "admin539@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { per_page: 2, starting_after: "your-cursor-from-response" }, - per_page: 5, - total_pages: 1, - }, - }; - server - .mockEndpoint() - .post("/tickets/search") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.tickets.searchTickets({ - query: { - operator: "AND", - value: [ - { - field: "created_at", - operator: ">", - value: "1306054154", - }, - ], - }, - pagination: { - per_page: 5, - }, - }); - expect(response).toEqual({ - type: "ticket.list", - tickets: [ - { - type: "ticket", - id: "633", - ticket_id: "40", - category: "Back-office", - ticket_attributes: { - _default_title_: "attribute_value", - }, - ticket_state: { - type: "ticket_state", - id: "8577", - category: "submitted", - internal_label: "Submitted", - external_label: "Submitted", - }, - ticket_type: { - type: "ticket_type", - id: "100", - category: "Back-office", - name: "my-ticket-type-35", - description: "my ticket type description is awesome.", - icon: "\uD83E\uDD81", - workspace_id: "this_is_an_id712_that_should_be_at_least_", - ticket_type_attributes: { - type: "list", - }, - archived: false, - created_at: 1734537989, - updated_at: 1734537989, - }, - contacts: { - type: "contact.list", - contacts: [ - { - type: "contact", - id: "6762f3061bb69f9f2193bc5b", - external_id: "9b913927-c084-4391-b1db-098341b5ffe3", - }, - ], - }, - admin_assignee_id: "0", - team_assignee_id: "0", - created_at: 1734537990, - updated_at: 1734537992, - open: true, - snoozed_until: 1663597260, - linked_objects: { - type: "list", - total_count: 0, - has_more: false, - data: [ - { - id: "7583", - }, - ], - }, - ticket_parts: { - type: "ticket_part.list", - ticket_parts: [ - { - type: "ticket_part", - id: "188", - part_type: "ticket_state_updated_by_admin", - body: "

Okay!

", - previous_ticket_state: "submitted", - ticket_state: "submitted", - created_at: 1734537991, - updated_at: 1734537991, - author: { - type: "admin", - id: "991268079", - name: "Ciaran539 Lee", - email: "admin539@email.com", - }, - attachments: [ - { - type: "upload", - name: "example.png", - url: "https://picsum.photos/200/300", - content_type: "image/png", - filesize: 100, - width: 100, - height: 100, - }, - ], - external_id: "abcd1234", - redacted: false, - app_package_code: "text-integration", - }, - ], - total_count: 1, - }, - is_shared: false, - }, - ], - total_count: 1, - pages: { - type: "pages", - page: 1, - next: { - per_page: 2, - starting_after: "your-cursor-from-response", - }, - per_page: 5, - total_pages: 1, - }, - }); - }); -}); diff --git a/tests/wire/unstable/visitors.test.ts b/tests/wire/unstable/visitors.test.ts deleted file mode 100644 index b9c5c9b0..00000000 --- a/tests/wire/unstable/visitors.test.ts +++ /dev/null @@ -1,866 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("VisitorsClient", () => { - test("retrieveVisitorWithUserId (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "visitor", - id: "6762f3101bb69f9f2193bc64", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Jane Doe", - pseudonym: "Red Duck from Dublin", - avatar: { type: "avatar", image_url: "https://example.com/avatar.png" }, - app_id: "this_is_an_id722_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734538000, - remote_created_at: 1734538000, - signed_up_at: 1734538000, - updated_at: 1734538000, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.unstable.visitors.retrieveVisitorWithUserId({ - user_id: "user_id", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f3101bb69f9f2193bc64", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Jane Doe", - pseudonym: "Red Duck from Dublin", - avatar: { - type: "avatar", - image_url: "https://example.com/avatar.png", - }, - app_id: "this_is_an_id722_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734538000, - remote_created_at: 1734538000, - signed_up_at: 1734538000, - updated_at: 1734538000, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("retrieveVisitorWithUserId (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.visitors.retrieveVisitorWithUserId({ - user_id: "user_id", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("retrieveVisitorWithUserId (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.unstable.visitors.retrieveVisitorWithUserId({ - user_id: "user_id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("updateVisitor (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "6762f30c1bb69f9f2193bc5e", name: "Gareth Bale" }; - const rawResponseBody = { - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.visitors.updateVisitor({ - id: "6762f30c1bb69f9f2193bc5e", - name: "Gareth Bale", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("updateVisitor (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { user_id: "fail", name: "Christian Fail" }; - const rawResponseBody = { - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.visitors.updateVisitor({ - user_id: "fail", - name: "Christian Fail", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: "custom_attributes", - monthly_spend: "custom_attributes", - team_mates: "custom_attributes", - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("updateVisitor (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.visitors.updateVisitor({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); - - test("updateVisitor (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { key: "value" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.visitors.updateVisitor({ - key: "value", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); - - test("convertVisitor (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "user", - user: { email: "foo@bar.com" }, - visitor: { user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" }, - }; - const rawResponseBody = { - type: "contact", - id: "6762f3141bb69f9f2193bc6b", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id728_that_should_be_at_least_", - role: "user", - email: "foo@bar.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734538004, - updated_at: 1734538005, - signed_up_at: 1734538004, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: { type: "avatar", image_url: "https://example.org/128Wash.jpg" }, - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { - data: [{ type: "social_profile", name: "Facebook", url: "http://twitter.com/th1sland" }], - }, - }; - server - .mockEndpoint() - .post("/visitors/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.visitors.convertVisitor({ - type: "user", - user: { - email: "foo@bar.com", - }, - visitor: { - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - }, - }); - expect(response).toEqual({ - type: "contact", - id: "6762f3141bb69f9f2193bc6b", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id728_that_should_be_at_least_", - role: "user", - email: "foo@bar.com", - email_domain: "example.com", - phone: "+1123456789", - formatted_phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734538004, - updated_at: 1734538005, - signed_up_at: 1734538004, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: { - type: "avatar", - image_url: "https://example.org/128Wash.jpg", - }, - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - type: "social_profile", - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - }); - }); - - test("convertVisitor (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { type: "type", user: { key: "value" }, visitor: { key: "value" } }; - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/visitors/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.visitors.convertVisitor({ - type: "type", - user: { - key: "value", - }, - visitor: { - key: "value", - }, - }); - }).rejects.toThrow(Intercom.unstable.UnauthorizedError); - }); -}); diff --git a/tests/wire/unstable/workflows.test.ts b/tests/wire/unstable/workflows.test.ts deleted file mode 100644 index b4035d7f..00000000 --- a/tests/wire/unstable/workflows.test.ts +++ /dev/null @@ -1,131 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../../src/api/index"; -import { IntercomClient } from "../../../src/Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("WorkflowsClient", () => { - test("exportWorkflow (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - export_version: "1.0", - exported_at: "2026-01-26T12:00:00Z", - app_id: 12345, - workflow: { - id: "67890", - title: "My Workflow", - description: "A workflow that handles customer inquiries", - trigger_type: "inbound_conversation", - state: "live", - target_channels: ["chat"], - preferred_devices: ["desktop", "mobile"], - created_at: "2025-06-15T10:30:00Z", - updated_at: "2026-01-20T14:45:00Z", - targeting: { key: "value" }, - snapshot: { key: "value" }, - attributes: [{ key: "value" }], - embedded_rules: [{ key: "value" }], - }, - }; - server - .mockEndpoint() - .get("/export/workflows/12345") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.unstable.workflows.exportWorkflow({ - id: "12345", - }); - expect(response).toEqual({ - export_version: "1.0", - exported_at: "2026-01-26T12:00:00Z", - app_id: 12345, - workflow: { - id: "67890", - title: "My Workflow", - description: "A workflow that handles customer inquiries", - trigger_type: "inbound_conversation", - state: "live", - target_channels: ["chat"], - preferred_devices: ["desktop", "mobile"], - created_at: "2025-06-15T10:30:00Z", - updated_at: "2026-01-20T14:45:00Z", - targeting: { - key: "value", - }, - snapshot: { - key: "value", - }, - attributes: [ - { - key: "value", - }, - ], - embedded_rules: [ - { - key: "value", - }, - ], - }, - }); - }); - - test("exportWorkflow (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "type", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .get("/export/workflows/id") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.workflows.exportWorkflow({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.ForbiddenError); - }); - - test("exportWorkflow (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .get("/export/workflows/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.unstable.workflows.exportWorkflow({ - id: "id", - }); - }).rejects.toThrow(Intercom.unstable.NotFoundError); - }); -}); diff --git a/tests/wire/visitors.test.ts b/tests/wire/visitors.test.ts deleted file mode 100644 index 7adbb5f2..00000000 --- a/tests/wire/visitors.test.ts +++ /dev/null @@ -1,847 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Intercom from "../../src/api/index"; -import { IntercomClient } from "../../src/Client"; -import { mockServerPool } from "../mock-server/MockServerPool"; - -describe("VisitorsClient", () => { - test("find (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { - type: "visitor", - id: "6762f3101bb69f9f2193bc64", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Jane Doe", - pseudonym: "Red Duck from Dublin", - avatar: { type: "avatar", image_url: "https://example.com/avatar.png" }, - app_id: "this_is_an_id722_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734538000, - remote_created_at: 1734538000, - signed_up_at: 1734538000, - updated_at: 1734538000, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); - - const response = await client.visitors.find({ - user_id: "user_id", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f3101bb69f9f2193bc64", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Jane Doe", - pseudonym: "Red Duck from Dublin", - avatar: { - type: "avatar", - image_url: "https://example.com/avatar.png", - }, - app_id: "this_is_an_id722_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: true, - monthly_spend: 155.5, - team_mates: 9, - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734538000, - remote_created_at: 1734538000, - signed_up_at: 1734538000, - updated_at: 1734538000, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("find (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.visitors.find({ - user_id: "user_id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("find (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - - const rawResponseBody = { key: "value" }; - server.mockEndpoint().get("/visitors").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); - - await expect(async () => { - return await client.visitors.find({ - user_id: "user_id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "6762f30c1bb69f9f2193bc5e", name: "Gareth Bale" }; - const rawResponseBody = { - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.visitors.update({ - id: "6762f30c1bb69f9f2193bc5e", - name: "Gareth Bale", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: true, - monthly_spend: 155.5, - team_mates: 9, - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { user_id: "fail", name: "Christian Fail" }; - const rawResponseBody = { - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { paid_subscriber: true, monthly_spend: 155.5, team_mates: 9 }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { type: "social_profile.list", social_profiles: ["social_profiles"] }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { type: "tag.list", tags: [{ id: "8482", name: "tag_name" }] }, - segments: { type: "segment.list", segments: ["segments"] }, - custom_attributes: { key: "value" }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.visitors.update({ - user_id: "fail", - name: "Christian Fail", - }); - expect(response).toEqual({ - type: "visitor", - id: "6762f30c1bb69f9f2193bc5e", - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - anonymous: true, - email: "", - phone: "555-555-5555", - name: "Gareth Bale", - pseudonym: "Violet Suitcase", - avatar: { - type: "avatar", - image_url: "https://static.intercomassets.com/app/pseudonym_avatars_2019/violet-suitcase.png", - }, - app_id: "this_is_an_id716_that_should_be_at_least_", - companies: { - type: "company.list", - companies: [ - { - id: "531ee472cce572a6ec000006", - name: "Blue Sun", - app_id: "ecahpwf5", - company_id: "6", - remote_created_at: 1663597223, - created_at: 1663597223, - updated_at: 1663597223, - last_request_at: 1663597223, - size: 100, - website: "https://www.intercom.com", - industry: "Software", - monthly_spend: 100, - session_count: 100, - user_count: 100, - custom_attributes: { - paid_subscriber: true, - monthly_spend: 155.5, - team_mates: 9, - }, - }, - ], - }, - location_data: { - type: "location_data", - city_name: "Dublin", - continent_code: "EU", - country_code: "IRL", - country_name: "Ireland", - postal_code: "D02 N960", - region_name: "Leinster", - timezone: "Europe/Dublin", - }, - las_request_at: 1663597260, - created_at: 1734537996, - remote_created_at: 1734537996, - signed_up_at: 1734537996, - updated_at: 1734537997, - session_count: 0, - social_profiles: { - type: "social_profile.list", - social_profiles: ["social_profiles"], - }, - owner_id: "5169261", - unsubscribed_from_emails: false, - marked_email_as_spam: false, - has_hard_bounced: false, - tags: { - type: "tag.list", - tags: [ - { - id: "8482", - name: "tag_name", - }, - ], - }, - segments: { - type: "segment.list", - segments: ["segments"], - }, - custom_attributes: { - key: "value", - }, - referrer: "https://www.google.com/", - utm_campaign: "intercom-link", - utm_content: "banner", - utm_medium: "email", - utm_source: "Intercom", - utm_term: "messenger", - do_not_track: false, - }); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.visitors.update({ - id: "id", - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { id: "id" }; - const rawResponseBody = { key: "value" }; - server - .mockEndpoint() - .put("/visitors") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.visitors.update({ - id: "id", - }); - }).rejects.toThrow(Intercom.NotFoundError); - }); - - test("mergeToContact (1)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { - type: "user", - user: { id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", email: "foo@bar.com" }, - visitor: { user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" }, - }; - const rawResponseBody = { - type: "contact", - id: "6762f3141bb69f9f2193bc6b", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id728_that_should_be_at_least_", - role: "user", - email: "foo@bar.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734538004, - updated_at: 1734538005, - signed_up_at: 1734538004, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { key: "value" }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [{ type: "note", id: "123", url: "/contacts/5ba682d23d7cf92bef87bfd4/notes" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [{ id: "5ba682d23d7cf92bef87bfd4", url: "/companies/5ba682d23d7cf92bef87bfd4" }], - url: "/contacts/6762f3141bb69f9f2193bc6b/companies", - total_count: 0, - has_more: false, - }, - location: { type: "location", country: "Ireland", region: "Dublin", city: "Dublin" }, - social_profiles: { data: [{ name: "Facebook", url: "http://twitter.com/th1sland" }] }, - }; - server - .mockEndpoint() - .post("/visitors/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.visitors.mergeToContact({ - type: "user", - user: { - id: "8a88a590-e1c3-41e2-a502-e0649dbf721c", - email: "foo@bar.com", - }, - visitor: { - user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", - }, - }); - expect(response).toEqual({ - type: "contact", - id: "6762f3141bb69f9f2193bc6b", - external_id: "f3b87a2e09d514c6c2e79b9a", - workspace_id: "this_is_an_id728_that_should_be_at_least_", - role: "user", - email: "foo@bar.com", - email_domain: "example.com", - phone: "+1123456789", - name: "John Doe", - owner_id: 123, - has_hard_bounced: false, - marked_email_as_spam: false, - unsubscribed_from_emails: false, - created_at: 1734538004, - updated_at: 1734538005, - signed_up_at: 1734538004, - last_seen_at: 1571672154, - last_replied_at: 1571672154, - last_contacted_at: 1571672154, - last_email_opened_at: 1571672154, - last_email_clicked_at: 1571672154, - language_override: "en", - browser: "Chrome", - browser_version: "80.0.3987.132", - browser_language: "en-US", - os: "Mac OS X", - android_app_name: "Intercom", - android_app_version: "5.0.0", - android_device: "Pixel 3", - android_os_version: "10", - android_sdk_version: "28", - android_last_seen_at: 1571672154, - ios_app_name: "Intercom", - ios_app_version: "5.0.0", - ios_device: "iPhone 11", - ios_os_version: "13.3.1", - ios_sdk_version: "13.3.1", - ios_last_seen_at: 1571672154, - custom_attributes: { - key: "value", - }, - avatar: "https://example.org/128Wash.jpg", - tags: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/tags", - total_count: 0, - has_more: false, - }, - notes: { - data: [ - { - type: "note", - id: "123", - url: "/contacts/5ba682d23d7cf92bef87bfd4/notes", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/notes", - total_count: 0, - has_more: false, - }, - companies: { - data: [ - { - id: "5ba682d23d7cf92bef87bfd4", - url: "/companies/5ba682d23d7cf92bef87bfd4", - }, - ], - url: "/contacts/6762f3141bb69f9f2193bc6b/companies", - total_count: 0, - has_more: false, - }, - location: { - type: "location", - country: "Ireland", - region: "Dublin", - city: "Dublin", - }, - social_profiles: { - data: [ - { - name: "Facebook", - url: "http://twitter.com/th1sland", - }, - ], - }, - }); - }); - - test("mergeToContact (2)", async () => { - const server = mockServerPool.createServer(); - const client = new IntercomClient({ - maxRetries: 0, - token: "test", - version: "2.14", - environment: server.baseUrl, - }); - const rawRequestBody = { type: "type", user: { id: "id" }, visitor: { id: "id" } }; - const rawResponseBody = { type: "error.list", errors: [{ code: "code" }, { code: "code" }] }; - server - .mockEndpoint() - .post("/visitors/convert") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.visitors.mergeToContact({ - type: "type", - user: { - id: "id", - }, - visitor: { - id: "id", - }, - }); - }).rejects.toThrow(Intercom.UnauthorizedError); - }); -}); diff --git a/tsc-multi.json b/tsc-multi.json new file mode 100644 index 00000000..4facad5a --- /dev/null +++ b/tsc-multi.json @@ -0,0 +1,7 @@ +{ + "targets": [ + { "extname": ".js", "module": "commonjs" }, + { "extname": ".mjs", "module": "esnext" } + ], + "projects": ["tsconfig.build.json"] +} diff --git a/tsconfig.base.json b/tsconfig.base.json deleted file mode 100644 index d7627675..00000000 --- a/tsconfig.base.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "extendedDiagnostics": true, - "strict": true, - "target": "ES6", - "moduleResolution": "node", - "esModuleInterop": true, - "skipLibCheck": true, - "declaration": true, - "outDir": "dist", - "rootDir": "src", - "baseUrl": "src", - "isolatedModules": true, - "isolatedDeclarations": true - }, - "include": ["src"], - "exclude": [] -} diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..cfddc8e7 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + "extends": "./tsconfig.json", + "include": ["dist/src"], + "exclude": ["dist/src/_shims/*-deno.ts"], + "compilerOptions": { + "rootDir": "./dist/src", + "paths": { + "intercom-client/*": ["dist/src/*"], + "intercom-client": ["dist/src/index.ts"], + }, + "noEmit": false, + "declaration": true, + "declarationMap": true, + "outDir": "dist", + "pretty": true, + "sourceMap": true + } +} diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json deleted file mode 100644 index 5c11446f..00000000 --- a/tsconfig.cjs.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "module": "CommonJS", - "outDir": "dist/cjs" - }, - "include": ["src"], - "exclude": [] -} diff --git a/tsconfig.deno.json b/tsconfig.deno.json new file mode 100644 index 00000000..448b100b --- /dev/null +++ b/tsconfig.deno.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "include": ["deno"], + "exclude": [], + "compilerOptions": { + "rootDir": "./deno", + "lib": ["es2020", "DOM"], + "paths": { + "intercom-client/_shims/auto/*": ["deno/_shims/auto/*-deno"], + "intercom-client/*": ["deno/*"], + "intercom-client": ["deno/index.ts"], + }, + "noEmit": true, + "declaration": true, + "declarationMap": true, + "outDir": "deno", + "pretty": true, + "sourceMap": true + } +} diff --git a/tsconfig.dist-src.json b/tsconfig.dist-src.json new file mode 100644 index 00000000..e9f2d70b --- /dev/null +++ b/tsconfig.dist-src.json @@ -0,0 +1,11 @@ +{ + // this config is included in the published src directory to prevent TS errors + // from appearing when users go to source, and VSCode opens the source .ts file + // via declaration maps + "include": ["index.ts"], + "compilerOptions": { + "target": "es2015", + "lib": ["DOM"], + "moduleResolution": "node" + } +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index 6ce90974..00000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.base.json", - "compilerOptions": { - "module": "esnext", - "outDir": "dist/esm", - "verbatimModuleSyntax": true - }, - "include": ["src"], - "exclude": [] -} diff --git a/tsconfig.json b/tsconfig.json index d77fdf00..077a86bc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,38 @@ { - "extends": "./tsconfig.cjs.json" + "include": ["src", "tests", "examples"], + "exclude": ["src/_shims/**/*-deno.ts"], + "compilerOptions": { + "target": "es2020", + "lib": ["es2020"], + "module": "commonjs", + "moduleResolution": "node", + "esModuleInterop": true, + "baseUrl": "./", + "paths": { + "intercom-client/_shims/auto/*": ["src/_shims/auto/*-node"], + "intercom-client/*": ["src/*"], + "intercom-client": ["src/index.ts"], + }, + "noEmit": true, + + "resolveJsonModule": true, + + "forceConsistentCasingInFileNames": true, + + "strict": true, + "noImplicitAny": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictBindCallApply": true, + "strictPropertyInitialization": true, + "noImplicitThis": true, + "noImplicitReturns": true, + "alwaysStrict": true, + "exactOptionalPropertyTypes": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + + "skipLibCheck": true + } } diff --git a/vitest.config.mts b/vitest.config.mts deleted file mode 100644 index ba2ec4f9..00000000 --- a/vitest.config.mts +++ /dev/null @@ -1,28 +0,0 @@ -import { defineConfig } from "vitest/config"; -export default defineConfig({ - test: { - projects: [ - { - test: { - globals: true, - name: "unit", - environment: "node", - root: "./tests", - include: ["**/*.test.{js,ts,jsx,tsx}"], - exclude: ["wire/**"], - setupFiles: ["./setup.ts"], - }, - }, - { - test: { - globals: true, - name: "wire", - environment: "node", - root: "./tests/wire", - setupFiles: ["../setup.ts", "../mock-server/setup.ts"], - }, - }, - ], - passWithNoTests: true, - }, -}); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 00000000..91bd58e5 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,3604 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@aashutoshrathi/word-wrap@^1.2.3": + version "1.2.6" + resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf" + integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA== + +"@ampproject/remapping@^2.2.0": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" + integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== + dependencies: + "@jridgewell/gen-mapping" "^0.3.0" + "@jridgewell/trace-mapping" "^0.3.9" + +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" + integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA== + dependencies: + "@babel/highlight" "^7.23.4" + chalk "^2.4.2" + +"@babel/compat-data@^7.23.5": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.5.tgz#ffb878728bb6bdcb6f4510aa51b1be9afb8cfd98" + integrity sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw== + +"@babel/core@^7.11.6", "@babel/core@^7.12.3": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.23.6.tgz#8be77cd77c55baadcc1eae1c33df90ab6d2151d4" + integrity sha512-FxpRyGjrMJXh7X3wGLGhNDCRiwpWEF74sKjTLDJSG5Kyvow3QZaG0Adbqzi9ZrVjTWpsX+2cxWXD71NMg93kdw== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-compilation-targets" "^7.23.6" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helpers" "^7.23.6" + "@babel/parser" "^7.23.6" + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.6" + "@babel/types" "^7.23.6" + 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.23.6", "@babel/generator@^7.7.2": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.23.6.tgz#9e1fca4811c77a10580d17d26b57b036133f3c2e" + integrity sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw== + dependencies: + "@babel/types" "^7.23.6" + "@jridgewell/gen-mapping" "^0.3.2" + "@jridgewell/trace-mapping" "^0.3.17" + jsesc "^2.5.1" + +"@babel/helper-compilation-targets@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz#4d79069b16cbcf1461289eccfbbd81501ae39991" + integrity sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ== + dependencies: + "@babel/compat-data" "^7.23.5" + "@babel/helper-validator-option" "^7.23.5" + browserslist "^4.22.2" + lru-cache "^5.1.1" + semver "^6.3.1" + +"@babel/helper-environment-visitor@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167" + integrity sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA== + +"@babel/helper-function-name@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz#1f9a3cdbd5b2698a670c30d2735f9af95ed52759" + integrity sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw== + dependencies: + "@babel/template" "^7.22.15" + "@babel/types" "^7.23.0" + +"@babel/helper-hoist-variables@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb" + integrity sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-module-imports@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" + integrity sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w== + dependencies: + "@babel/types" "^7.22.15" + +"@babel/helper-module-transforms@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz#d7d12c3c5d30af5b3c0fcab2a6d5217773e2d0f1" + integrity sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ== + dependencies: + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-simple-access" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/helper-validator-identifier" "^7.22.20" + +"@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.22.5", "@babel/helper-plugin-utils@^7.8.0": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295" + integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg== + +"@babel/helper-simple-access@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" + integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-split-export-declaration@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" + integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-string-parser@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83" + integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ== + +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== + +"@babel/helper-validator-option@^7.23.5": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307" + integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw== + +"@babel/helpers@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.6.tgz#d03af2ee5fb34691eec0cda90f5ecbb4d4da145a" + integrity sha512-wCfsbN4nBidDRhpDhvcKlzHWCTlgJYUUdSJfzXb2NuBssDSIjc3xcb+znA7l+zYsFljAcGM0aFkN40cR3lXiGA== + dependencies: + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.6" + "@babel/types" "^7.23.6" + +"@babel/highlight@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" + integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== + dependencies: + "@babel/helper-validator-identifier" "^7.22.20" + chalk "^2.4.2" + js-tokens "^4.0.0" + +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.15", "@babel/parser@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.6.tgz#ba1c9e512bda72a47e285ae42aff9d2a635a9e3b" + integrity sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ== + +"@babel/plugin-syntax-async-generators@^7.8.4": + version "7.8.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" + integrity sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-bigint@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz#4c9a6f669f5d0cdf1b90a1671e9a146be5300cea" + integrity sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-class-properties@^7.8.3": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz#b5c987274c4a3a82b89714796931a6b53544ae10" + integrity sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA== + dependencies: + "@babel/helper-plugin-utils" "^7.12.13" + +"@babel/plugin-syntax-import-meta@^7.8.3": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz#ee601348c370fa334d2207be158777496521fd51" + integrity sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-json-strings@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a" + integrity sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-jsx@^7.7.2": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473" + integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-syntax-logical-assignment-operators@^7.8.3": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699" + integrity sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-nullish-coalescing-operator@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz#167ed70368886081f74b5c36c65a88c03b66d1a9" + integrity sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-numeric-separator@^7.8.3": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz#b9b070b3e33570cd9fd07ba7fa91c0dd37b9af97" + integrity sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== + dependencies: + "@babel/helper-plugin-utils" "^7.10.4" + +"@babel/plugin-syntax-object-rest-spread@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz#60e225edcbd98a640332a2e72dd3e66f1af55871" + integrity sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-optional-catch-binding@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz#6111a265bcfb020eb9efd0fdfd7d26402b9ed6c1" + integrity sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-optional-chaining@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz#4f69c2ab95167e0180cd5336613f8c5788f7d48a" + integrity sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.0" + +"@babel/plugin-syntax-top-level-await@^7.8.3": + version "7.14.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz#c1cfdadc35a646240001f06138247b741c34d94c" + integrity sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw== + dependencies: + "@babel/helper-plugin-utils" "^7.14.5" + +"@babel/plugin-syntax-typescript@^7.7.2": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f" + integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/template@^7.22.15", "@babel/template@^7.3.3": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" + integrity sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w== + dependencies: + "@babel/code-frame" "^7.22.13" + "@babel/parser" "^7.22.15" + "@babel/types" "^7.22.15" + +"@babel/traverse@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.6.tgz#b53526a2367a0dd6edc423637f3d2d0f2521abc5" + integrity sha512-czastdK1e8YByZqezMPFiZ8ahwVMh/ESl9vPgvgdB9AmFMGP5jfpFax74AQgl5zj4XHzqeYAg2l8PuUeRS1MgQ== + dependencies: + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-hoist-variables" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/parser" "^7.23.6" + "@babel/types" "^7.23.6" + debug "^4.3.1" + globals "^11.1.0" + +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.22.15", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.6", "@babel/types@^7.3.3": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.6.tgz#be33fdb151e1f5a56877d704492c240fc71c7ccd" + integrity sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg== + dependencies: + "@babel/helper-string-parser" "^7.23.4" + "@babel/helper-validator-identifier" "^7.22.20" + to-fast-properties "^2.0.0" + +"@bcoe/v8-coverage@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" + integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== + +"@cspotcode/source-map-consumer@0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b" + integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg== + +"@cspotcode/source-map-support@0.7.0": + version "0.7.0" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5" + integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA== + dependencies: + "@cspotcode/source-map-consumer" "0.8.0" + +"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.5.1": + version "4.9.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.9.0.tgz#7ccb5f58703fa61ffdcbf39e2c604a109e781162" + integrity sha512-zJmuCWj2VLBt4c25CfBIbMZLGLyhkvs7LznyVX5HfpzeocThgIj5XQK4L+g3U36mMcx8bPMhGyPpwCATamC4jQ== + +"@eslint-community/regexpp@^4.6.1": + version "4.6.2" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.6.2.tgz#1816b5f6948029c5eaacb0703b850ee0cb37d8f8" + integrity sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw== + +"@eslint/eslintrc@^2.1.2": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.2.tgz#c6936b4b328c64496692f76944e755738be62396" + integrity sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.6.0" + globals "^13.19.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + +"@eslint/js@8.50.0": + version "8.50.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.50.0.tgz#9e93b850f0f3fa35f5fa59adfd03adae8488e484" + integrity sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ== + +"@humanwhocodes/config-array@^0.11.11": + version "0.11.11" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.11.tgz#88a04c570dbbc7dd943e4712429c3df09bc32844" + integrity sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA== + dependencies: + "@humanwhocodes/object-schema" "^1.2.1" + debug "^4.1.1" + minimatch "^3.0.5" + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== + +"@humanwhocodes/object-schema@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== + +"@istanbuljs/load-nyc-config@^1.0.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" + integrity sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ== + dependencies: + camelcase "^5.3.1" + find-up "^4.1.0" + get-package-type "^0.1.0" + js-yaml "^3.13.1" + resolve-from "^5.0.0" + +"@istanbuljs/schema@^0.1.2": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" + integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== + +"@jest/console@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-29.7.0.tgz#cd4822dbdb84529265c5a2bdb529a3c9cc950ffc" + integrity sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + slash "^3.0.0" + +"@jest/core@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-29.7.0.tgz#b6cccc239f30ff36609658c5a5e2291757ce448f" + integrity sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg== + dependencies: + "@jest/console" "^29.7.0" + "@jest/reporters" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + ansi-escapes "^4.2.1" + chalk "^4.0.0" + ci-info "^3.2.0" + exit "^0.1.2" + graceful-fs "^4.2.9" + jest-changed-files "^29.7.0" + jest-config "^29.7.0" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-resolve-dependencies "^29.7.0" + jest-runner "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + jest-watcher "^29.7.0" + micromatch "^4.0.4" + pretty-format "^29.7.0" + slash "^3.0.0" + strip-ansi "^6.0.0" + +"@jest/create-cache-key-function@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-29.7.0.tgz#793be38148fab78e65f40ae30c36785f4ad859f0" + integrity sha512-4QqS3LY5PBmTRHj9sAg1HLoPzqAI0uOX6wI/TRqHIcOxlFidy6YEmCQJk6FSZjNLGCeubDMfmkWL+qaLKhSGQA== + dependencies: + "@jest/types" "^29.6.3" + +"@jest/environment@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.7.0.tgz#24d61f54ff1f786f3cd4073b4b94416383baf2a7" + integrity sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw== + dependencies: + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-mock "^29.7.0" + +"@jest/expect-utils@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.7.0.tgz#023efe5d26a8a70f21677d0a1afc0f0a44e3a1c6" + integrity sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA== + dependencies: + jest-get-type "^29.6.3" + +"@jest/expect@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/expect/-/expect-29.7.0.tgz#76a3edb0cb753b70dfbfe23283510d3d45432bf2" + integrity sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ== + dependencies: + expect "^29.7.0" + jest-snapshot "^29.7.0" + +"@jest/fake-timers@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.7.0.tgz#fd91bf1fffb16d7d0d24a426ab1a47a49881a565" + integrity sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ== + dependencies: + "@jest/types" "^29.6.3" + "@sinonjs/fake-timers" "^10.0.2" + "@types/node" "*" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-util "^29.7.0" + +"@jest/globals@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-29.7.0.tgz#8d9290f9ec47ff772607fa864ca1d5a2efae1d4d" + integrity sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/types" "^29.6.3" + jest-mock "^29.7.0" + +"@jest/reporters@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-29.7.0.tgz#04b262ecb3b8faa83b0b3d321623972393e8f4c7" + integrity sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg== + dependencies: + "@bcoe/v8-coverage" "^0.2.3" + "@jest/console" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" + "@types/node" "*" + chalk "^4.0.0" + collect-v8-coverage "^1.0.0" + exit "^0.1.2" + glob "^7.1.3" + graceful-fs "^4.2.9" + istanbul-lib-coverage "^3.0.0" + istanbul-lib-instrument "^6.0.0" + istanbul-lib-report "^3.0.0" + istanbul-lib-source-maps "^4.0.0" + istanbul-reports "^3.1.3" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + jest-worker "^29.7.0" + slash "^3.0.0" + string-length "^4.0.1" + strip-ansi "^6.0.0" + v8-to-istanbul "^9.0.1" + +"@jest/schemas@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" + integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== + dependencies: + "@sinclair/typebox" "^0.27.8" + +"@jest/source-map@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.6.3.tgz#d90ba772095cf37a34a5eb9413f1b562a08554c4" + integrity sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw== + dependencies: + "@jridgewell/trace-mapping" "^0.3.18" + callsites "^3.0.0" + graceful-fs "^4.2.9" + +"@jest/test-result@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-29.7.0.tgz#8db9a80aa1a097bb2262572686734baed9b1657c" + integrity sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA== + dependencies: + "@jest/console" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/istanbul-lib-coverage" "^2.0.0" + collect-v8-coverage "^1.0.0" + +"@jest/test-sequencer@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz#6cef977ce1d39834a3aea887a1726628a6f072ce" + integrity sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw== + dependencies: + "@jest/test-result" "^29.7.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + slash "^3.0.0" + +"@jest/transform@^29.7.0": + version "29.7.0" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-29.7.0.tgz#df2dd9c346c7d7768b8a06639994640c642e284c" + integrity sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw== + dependencies: + "@babel/core" "^7.11.6" + "@jest/types" "^29.6.3" + "@jridgewell/trace-mapping" "^0.3.18" + babel-plugin-istanbul "^6.1.1" + chalk "^4.0.0" + convert-source-map "^2.0.0" + fast-json-stable-stringify "^2.1.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" + micromatch "^4.0.4" + pirates "^4.0.4" + slash "^3.0.0" + write-file-atomic "^4.0.2" + +"@jest/types@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" + integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== + dependencies: + "@jest/schemas" "^29.6.3" + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^17.0.8" + chalk "^4.0.0" + +"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" + integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== + dependencies: + "@jridgewell/set-array" "^1.0.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" + +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" + integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== + +"@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== + +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.18", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.20" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.20.tgz#72e45707cf240fa6b081d0366f8265b0cd10197f" + integrity sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@pkgr/utils@^2.4.2": + version "2.4.2" + resolved "https://registry.yarnpkg.com/@pkgr/utils/-/utils-2.4.2.tgz#9e638bbe9a6a6f165580dc943f138fd3309a2cbc" + integrity sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw== + dependencies: + cross-spawn "^7.0.3" + fast-glob "^3.3.0" + is-glob "^4.0.3" + open "^9.1.0" + picocolors "^1.0.0" + tslib "^2.6.0" + +"@sinclair/typebox@^0.27.8": + version "0.27.8" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" + integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== + +"@sinonjs/commons@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.0.tgz#beb434fe875d965265e04722ccfc21df7f755d72" + integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA== + dependencies: + type-detect "4.0.8" + +"@sinonjs/fake-timers@^10.0.2": + version "10.3.0" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz#55fdff1ecab9f354019129daf4df0dd4d923ea66" + integrity sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA== + dependencies: + "@sinonjs/commons" "^3.0.0" + +"@swc/core-darwin-arm64@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.4.16.tgz#2cd45d709ce76d448d96bf8d0006849541436611" + integrity sha512-UOCcH1GvjRnnM/LWT6VCGpIk0OhHRq6v1U6QXuPt5wVsgXnXQwnf5k3sG5Cm56hQHDvhRPY6HCsHi/p0oek8oQ== + +"@swc/core-darwin-x64@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.4.16.tgz#a5bc7d8b1dd850adb0bb95c6b5c742b92201fd01" + integrity sha512-t3bgqFoYLWvyVtVL6KkFNCINEoOrIlyggT/kJRgi1y0aXSr0oVgcrQ4ezJpdeahZZ4N+Q6vT3ffM30yIunELNA== + +"@swc/core-linux-arm-gnueabihf@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.4.16.tgz#961744908ee5cbb79bc009dcf58cc8b831111f38" + integrity sha512-DvHuwvEF86YvSd0lwnzVcjOTZ0jcxewIbsN0vc/0fqm9qBdMMjr9ox6VCam1n3yYeRtj4VFgrjeNFksqbUejdQ== + +"@swc/core-linux-arm64-gnu@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.4.16.tgz#43713be3f26757d82d2745dc25f8b63400e0a3d0" + integrity sha512-9Uu5YlPbyCvbidjKtYEsPpyZlu16roOZ5c2tP1vHfnU9bgf5Tz5q5VovSduNxPHx+ed2iC1b1URODHvDzbbDuQ== + +"@swc/core-linux-arm64-musl@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.4.16.tgz#394a7d030f3a61902bd3947bb9d70d26d42f3c81" + integrity sha512-/YZq/qB1CHpeoL0eMzyqK5/tYZn/rzKoCYDviFU4uduSUIJsDJQuQA/skdqUzqbheOXKAd4mnJ1hT04RbJ8FPQ== + +"@swc/core-linux-x64-gnu@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.4.16.tgz#71eb108b784f9d551ee8a35ebcdaed972f567981" + integrity sha512-UUjaW5VTngZYDcA8yQlrFmqs1tLi1TxbKlnaJwoNhel9zRQ0yG1YEVGrzTvv4YApSuIiDK18t+Ip927bwucuVQ== + +"@swc/core-linux-x64-musl@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.4.16.tgz#10dbaedb4e3dfc7268e3a9a66ad3431471ef035b" + integrity sha512-aFhxPifevDTwEDKPi4eRYWzC0p/WYJeiFkkpNU5Uc7a7M5iMWPAbPFUbHesdlb9Jfqs5c07oyz86u+/HySBNPQ== + +"@swc/core-win32-arm64-msvc@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.4.16.tgz#80247adff6c245ff32b44d773c1a148858cd655f" + integrity sha512-bTD43MbhIHL2s5QgCwyleaGwl96Gk/scF2TaVKdUe4QlJCDV/YK9h5oIBAp63ckHtE8GHlH4c8dZNBiAXn4Org== + +"@swc/core-win32-ia32-msvc@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.4.16.tgz#e540afc3ccf3224267b4ddfb408f9d9737984686" + integrity sha512-/lmZeAN/qV5XbK2SEvi8e2RkIg8FQNYiSA8y2/Zb4gTUMKVO5JMLH0BSWMiIKMstKDPDSxMWgwJaQHF8UMyPmQ== + +"@swc/core-win32-x64-msvc@1.4.16": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.4.16.tgz#f880939fca32c181adfe7e3abd2b6b7857bd3489" + integrity sha512-BPAfFfODWXtUu6SwaTTftDHvcbDyWBSI/oanUeRbQR5vVWkXoQ3cxLTsDluc3H74IqXS5z1Uyoe0vNo2hB1opA== + +"@swc/core@^1.3.102": + version "1.4.16" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.4.16.tgz#d175bae2acfecd53bcbd4293f1fba5ec316634a0" + integrity sha512-Xaf+UBvW6JNuV131uvSNyMXHn+bh6LyKN4tbv7tOUFQpXyz/t9YWRE04emtlUW9Y0qrm/GKFCbY8n3z6BpZbTA== + dependencies: + "@swc/counter" "^0.1.2" + "@swc/types" "^0.1.5" + optionalDependencies: + "@swc/core-darwin-arm64" "1.4.16" + "@swc/core-darwin-x64" "1.4.16" + "@swc/core-linux-arm-gnueabihf" "1.4.16" + "@swc/core-linux-arm64-gnu" "1.4.16" + "@swc/core-linux-arm64-musl" "1.4.16" + "@swc/core-linux-x64-gnu" "1.4.16" + "@swc/core-linux-x64-musl" "1.4.16" + "@swc/core-win32-arm64-msvc" "1.4.16" + "@swc/core-win32-ia32-msvc" "1.4.16" + "@swc/core-win32-x64-msvc" "1.4.16" + +"@swc/counter@^0.1.2", "@swc/counter@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@swc/counter/-/counter-0.1.3.tgz#cc7463bd02949611c6329596fccd2b0ec782b0e9" + integrity sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ== + +"@swc/jest@^0.2.29": + version "0.2.36" + resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.36.tgz#2797450a30d28b471997a17e901ccad946fe693e" + integrity sha512-8X80dp81ugxs4a11z1ka43FPhP+/e+mJNXJSxiNYk8gIX/jPBtY4gQTrKu/KIoco8bzKuPI5lUxjfLiGsfvnlw== + dependencies: + "@jest/create-cache-key-function" "^29.7.0" + "@swc/counter" "^0.1.3" + jsonc-parser "^3.2.0" + +"@swc/types@^0.1.5": + version "0.1.6" + resolved "https://registry.yarnpkg.com/@swc/types/-/types-0.1.6.tgz#2f13f748995b247d146de2784d3eb7195410faba" + integrity sha512-/JLo/l2JsT/LRd80C3HfbmVpxOAJ11FO2RCEslFrgzLltoP9j8XIbsyDcfCt2WWyX+CM96rBoNM+IToAkFOugg== + dependencies: + "@swc/counter" "^0.1.3" + +"@ts-morph/common@~0.20.0": + version "0.20.0" + resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.20.0.tgz#3f161996b085ba4519731e4d24c35f6cba5b80af" + integrity sha512-7uKjByfbPpwuzkstL3L5MQyuXPSKdoNG93Fmi2JoDcTf3pEP731JdRFAduRVkOs8oqxPsXKA+ScrWkdQ8t/I+Q== + dependencies: + fast-glob "^3.2.12" + minimatch "^7.4.3" + mkdirp "^2.1.6" + path-browserify "^1.0.1" + +"@tsconfig/node10@^1.0.7": + version "1.0.8" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9" + integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg== + +"@tsconfig/node12@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c" + integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw== + +"@tsconfig/node14@^1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2" + integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg== + +"@tsconfig/node16@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e" + integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA== + +"@types/babel__core@^7.1.14": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" + integrity sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA== + dependencies: + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" + "@types/babel__generator" "*" + "@types/babel__template" "*" + "@types/babel__traverse" "*" + +"@types/babel__generator@*": + version "7.6.8" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.8.tgz#f836c61f48b1346e7d2b0d93c6dacc5b9535d3ab" + integrity sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw== + dependencies: + "@babel/types" "^7.0.0" + +"@types/babel__template@*": + version "7.4.4" + resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.4.4.tgz#5672513701c1b2199bc6dad636a9d7491586766f" + integrity sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A== + dependencies: + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": + version "7.20.4" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.20.4.tgz#ec2c06fed6549df8bc0eb4615b683749a4a92e1b" + integrity sha512-mSM/iKUk5fDDrEV/e83qY+Cr3I1+Q3qqTuEn++HAWYjEa1+NxZr6CNrcJGf2ZTnq4HoFGC3zaTPZTobCzCFukA== + dependencies: + "@babel/types" "^7.20.7" + +"@types/graceful-fs@^4.1.3": + version "4.1.9" + resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" + integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ== + dependencies: + "@types/node" "*" + +"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" + integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== + +"@types/istanbul-lib-report@*": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" + integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== + dependencies: + "@types/istanbul-lib-coverage" "*" + +"@types/istanbul-reports@^3.0.0": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" + integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== + dependencies: + "@types/istanbul-lib-report" "*" + +"@types/jest@^29.4.0": + version "29.5.11" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.11.tgz#0c13aa0da7d0929f078ab080ae5d4ced80fa2f2c" + integrity sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ== + dependencies: + expect "^29.0.0" + pretty-format "^29.0.0" + +"@types/json-schema@^7.0.12": + version "7.0.13" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.13.tgz#02c24f4363176d2d18fc8b70b9f3c54aba178a85" + integrity sha512-RbSSoHliUbnXj3ny0CNFOoxrIDV6SUGyStHsvDqosw6CkdPV8TtWGlfecuK4ToyMEAql6pzNxgCFKanovUzlgQ== + +"@types/node-fetch@^2.6.4": + version "2.6.4" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" + integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + +"@types/node@*": + version "20.10.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.5.tgz#47ad460b514096b7ed63a1dae26fad0914ed3ab2" + integrity sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw== + dependencies: + undici-types "~5.26.4" + +"@types/node@^18.11.18": + version "18.11.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" + integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== + +"@types/qs@^6.9.7": + version "6.9.15" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce" + integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg== + +"@types/semver@^7.5.0": + version "7.5.3" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.3.tgz#9a726e116beb26c24f1ccd6850201e1246122e04" + integrity sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw== + +"@types/stack-utils@^2.0.0": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" + integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== + +"@types/yargs-parser@*": + version "21.0.3" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" + integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== + +"@types/yargs@^17.0.8": + version "17.0.32" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.32.tgz#030774723a2f7faafebf645f4e5a48371dca6229" + integrity sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog== + dependencies: + "@types/yargs-parser" "*" + +"@typescript-eslint/eslint-plugin@^6.7.0": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.3.tgz#d98046e9f7102d49a93d944d413c6055c47fafd7" + integrity sha512-vntq452UHNltxsaaN+L9WyuMch8bMd9CqJ3zhzTPXXidwbf5mqqKCVXEuvRZUqLJSTLeWE65lQwyXsRGnXkCTA== + dependencies: + "@eslint-community/regexpp" "^4.5.1" + "@typescript-eslint/scope-manager" "6.7.3" + "@typescript-eslint/type-utils" "6.7.3" + "@typescript-eslint/utils" "6.7.3" + "@typescript-eslint/visitor-keys" "6.7.3" + debug "^4.3.4" + graphemer "^1.4.0" + ignore "^5.2.4" + natural-compare "^1.4.0" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/parser@^6.7.0": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.7.3.tgz#aaf40092a32877439e5957e18f2d6a91c82cc2fd" + integrity sha512-TlutE+iep2o7R8Lf+yoer3zU6/0EAUc8QIBB3GYBc1KGz4c4TRm83xwXUZVPlZ6YCLss4r77jbu6j3sendJoiQ== + dependencies: + "@typescript-eslint/scope-manager" "6.7.3" + "@typescript-eslint/types" "6.7.3" + "@typescript-eslint/typescript-estree" "6.7.3" + "@typescript-eslint/visitor-keys" "6.7.3" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.7.3.tgz#07e5709c9bdae3eaf216947433ef97b3b8b7d755" + integrity sha512-wOlo0QnEou9cHO2TdkJmzF7DFGvAKEnB82PuPNHpT8ZKKaZu6Bm63ugOTn9fXNJtvuDPanBc78lGUGGytJoVzQ== + dependencies: + "@typescript-eslint/types" "6.7.3" + "@typescript-eslint/visitor-keys" "6.7.3" + +"@typescript-eslint/type-utils@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.7.3.tgz#c2c165c135dda68a5e70074ade183f5ad68f3400" + integrity sha512-Fc68K0aTDrKIBvLnKTZ5Pf3MXK495YErrbHb1R6aTpfK5OdSFj0rVN7ib6Tx6ePrZ2gsjLqr0s98NG7l96KSQw== + dependencies: + "@typescript-eslint/typescript-estree" "6.7.3" + "@typescript-eslint/utils" "6.7.3" + debug "^4.3.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/types@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.7.3.tgz#0402b5628a63f24f2dc9d4a678e9a92cc50ea3e9" + integrity sha512-4g+de6roB2NFcfkZb439tigpAMnvEIg3rIjWQ+EM7IBaYt/CdJt6em9BJ4h4UpdgaBWdmx2iWsafHTrqmgIPNw== + +"@typescript-eslint/typescript-estree@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.3.tgz#ec5bb7ab4d3566818abaf0e4a8fa1958561b7279" + integrity sha512-YLQ3tJoS4VxLFYHTw21oe1/vIZPRqAO91z6Uv0Ss2BKm/Ag7/RVQBcXTGcXhgJMdA4U+HrKuY5gWlJlvoaKZ5g== + dependencies: + "@typescript-eslint/types" "6.7.3" + "@typescript-eslint/visitor-keys" "6.7.3" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + +"@typescript-eslint/utils@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.7.3.tgz#96c655816c373135b07282d67407cb577f62e143" + integrity sha512-vzLkVder21GpWRrmSR9JxGZ5+ibIUSudXlW52qeKpzUEQhRSmyZiVDDj3crAth7+5tmN1ulvgKaCU2f/bPRCzg== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@types/json-schema" "^7.0.12" + "@types/semver" "^7.5.0" + "@typescript-eslint/scope-manager" "6.7.3" + "@typescript-eslint/types" "6.7.3" + "@typescript-eslint/typescript-estree" "6.7.3" + semver "^7.5.4" + +"@typescript-eslint/visitor-keys@6.7.3": + version "6.7.3" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.3.tgz#83809631ca12909bd2083558d2f93f5747deebb2" + integrity sha512-HEVXkU9IB+nk9o63CeICMHxFWbHWr3E1mpilIQBe9+7L/lH97rleFLVtYsfnWB+JVMaiFnEaxvknvmIzX+CqVg== + dependencies: + "@typescript-eslint/types" "6.7.3" + eslint-visitor-keys "^3.4.1" + +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + +acorn-jsx@^5.3.2: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + +acorn@^8.4.1: + version "8.7.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" + integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== + +acorn@^8.9.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + +agentkeepalive@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.2.1.tgz#a7975cbb9f83b367f06c90cc51ff28fe7d499717" + integrity sha512-Zn4cw2NEqd+9fiSVWMscnjyQ1a8Yfoc5oBajLeo5w+YBHgDUcEBY2hS4YpTz6iN5f/2zQiktcuM6tS8x1p9dpA== + dependencies: + debug "^4.1.0" + depd "^1.1.2" + humanize-ms "^1.2.1" + +aggregate-error@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" + integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== + dependencies: + clean-stack "^2.0.0" + indent-string "^4.0.0" + +ajv@^6.12.4: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-escapes@^4.2.1: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + +anymatch@^3.0.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +array-union@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + +babel-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.7.0.tgz#f4369919225b684c56085998ac63dbd05be020d5" + integrity sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg== + dependencies: + "@jest/transform" "^29.7.0" + "@types/babel__core" "^7.1.14" + babel-plugin-istanbul "^6.1.1" + babel-preset-jest "^29.6.3" + chalk "^4.0.0" + graceful-fs "^4.2.9" + slash "^3.0.0" + +babel-plugin-istanbul@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz#fa88ec59232fd9b4e36dbbc540a8ec9a9b47da73" + integrity sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA== + dependencies: + "@babel/helper-plugin-utils" "^7.0.0" + "@istanbuljs/load-nyc-config" "^1.0.0" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-instrument "^5.0.4" + test-exclude "^6.0.0" + +babel-plugin-jest-hoist@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz#aadbe943464182a8922c3c927c3067ff40d24626" + integrity sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg== + dependencies: + "@babel/template" "^7.3.3" + "@babel/types" "^7.3.3" + "@types/babel__core" "^7.1.14" + "@types/babel__traverse" "^7.0.6" + +babel-preset-current-node-syntax@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz#b4399239b89b2a011f9ddbe3e4f401fc40cff73b" + integrity sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ== + dependencies: + "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/plugin-syntax-bigint" "^7.8.3" + "@babel/plugin-syntax-class-properties" "^7.8.3" + "@babel/plugin-syntax-import-meta" "^7.8.3" + "@babel/plugin-syntax-json-strings" "^7.8.3" + "@babel/plugin-syntax-logical-assignment-operators" "^7.8.3" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + "@babel/plugin-syntax-numeric-separator" "^7.8.3" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/plugin-syntax-top-level-await" "^7.8.3" + +babel-preset-jest@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz#fa05fa510e7d493896d7b0dd2033601c840f171c" + integrity sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA== + dependencies: + babel-plugin-jest-hoist "^29.6.3" + babel-preset-current-node-syntax "^1.0.0" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +big-integer@^1.6.44: + version "1.6.52" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85" + integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg== + +bplist-parser@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.2.0.tgz#43a9d183e5bf9d545200ceac3e712f79ebbe8d0e" + integrity sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw== + dependencies: + big-integer "^1.6.44" + +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== + 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== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browserslist@^4.22.2: + version "4.22.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.2.tgz#704c4943072bd81ea18997f3bd2180e89c77874b" + integrity sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A== + dependencies: + caniuse-lite "^1.0.30001565" + electron-to-chromium "^1.4.601" + node-releases "^2.0.14" + update-browserslist-db "^1.0.13" + +bs-logger@0.x: + version "0.2.6" + resolved "https://registry.yarnpkg.com/bs-logger/-/bs-logger-0.2.6.tgz#eb7d365307a72cf974cc6cda76b68354ad336bd8" + integrity sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog== + dependencies: + fast-json-stable-stringify "2.x" + +bser@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/bser/-/bser-2.1.1.tgz#e6787da20ece9d07998533cfd9de6f5c38f4bc05" + integrity sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ== + dependencies: + node-int64 "^0.4.0" + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +bundle-name@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-3.0.0.tgz#ba59bcc9ac785fb67ccdbf104a2bf60c099f0e1a" + integrity sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw== + dependencies: + run-applescript "^5.0.0" + +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +camelcase@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +camelcase@^6.2.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30001565: + version "1.0.30001570" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001570.tgz#b4e5c1fa786f733ab78fc70f592df6b3f23244ca" + integrity sha512-+3e0ASu4sw1SWaoCtvPeyXp+5PsjigkSt8OXZbF9StH5pQWbxEjLAZE3n8Aup5udop1uRiKA7a4utUk/uoSpUw== + +chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.0.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +char-regex@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" + integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== + +ci-info@^3.2.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" + integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== + +cjs-module-lexer@^1.0.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz#6c370ab19f8a3394e318fe682686ec0ac684d107" + integrity sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ== + +clean-stack@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== + +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== + +code-block-writer@^12.0.0: + version "12.0.0" + resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-12.0.0.tgz#4dd58946eb4234105aff7f0035977b2afdc2a770" + integrity sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w== + +collect-v8-coverage@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" + integrity sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q== + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +convert-source-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" + integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== + +create-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" + integrity sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q== + dependencies: + "@jest/types" "^29.6.3" + chalk "^4.0.0" + exit "^0.1.2" + graceful-fs "^4.2.9" + jest-config "^29.7.0" + jest-util "^29.7.0" + prompts "^2.0.1" + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +cross-spawn@^7.0.2, cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +dedent@^1.0.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/dedent/-/dedent-1.5.1.tgz#4f3fc94c8b711e9bb2800d185cd6ad20f2a90aff" + integrity sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg== + +deep-is@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== + +deepmerge@^4.2.2: + version "4.3.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" + integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== + +default-browser-id@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/default-browser-id/-/default-browser-id-3.0.0.tgz#bee7bbbef1f4e75d31f98f4d3f1556a14cea790c" + integrity sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA== + dependencies: + bplist-parser "^0.2.0" + untildify "^4.0.0" + +default-browser@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/default-browser/-/default-browser-4.0.0.tgz#53c9894f8810bf86696de117a6ce9085a3cbc7da" + integrity sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA== + dependencies: + bundle-name "^3.0.0" + default-browser-id "^3.0.0" + execa "^7.1.1" + titleize "^3.0.0" + +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +define-lazy-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" + integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + +depd@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= + +detect-newline@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" + integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== + +diff-sequences@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.6.3.tgz#4deaf894d11407c51efc8418012f9e70b84ea921" + integrity sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +dir-glob@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== + dependencies: + path-type "^4.0.0" + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +electron-to-chromium@^1.4.601: + version "1.4.614" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.614.tgz#2fe789d61fa09cb875569f37c309d0c2701f91c0" + integrity sha512-X4ze/9Sc3QWs6h92yerwqv7aB/uU8vCjZcrMjA8N9R1pjMFRe44dLsck5FzLilOYvcXuDn93B+bpGYyufc70gQ== + +emittery@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/emittery/-/emittery-0.13.1.tgz#c04b8c3457490e0847ae51fced3af52d338e3dad" + integrity sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +escape-string-regexp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz#a30304e99daa32e23b2fd20f51babd07cffca344" + integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== + +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-plugin-prettier@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.1.tgz#a3b399f04378f79f066379f544e42d6b73f11515" + integrity sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.8.5" + +eslint-plugin-unused-imports@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.0.0.tgz#d25175b0072ff16a91892c3aa72a09ca3a9e69e7" + integrity sha512-sduiswLJfZHeeBJ+MQaG+xYzSWdRXoSw61DpU13mzWumCkR0ufD0HmO4kdNokjrkluMHpj/7PJeN35pgbhW3kw== + dependencies: + eslint-rule-composer "^0.3.0" + +eslint-rule-composer@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9" + integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== + +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: + version "3.4.2" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz#8c2095440eca8c933bedcadf16fefa44dbe9ba5f" + integrity sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw== + +eslint-visitor-keys@^3.4.3: + version "3.4.3" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" + integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== + +eslint@^8.49.0: + version "8.50.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.50.0.tgz#2ae6015fee0240fcd3f83e1e25df0287f487d6b2" + integrity sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.2" + "@eslint/js" "8.50.0" + "@humanwhocodes/config-array" "^0.11.11" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + ajv "^6.12.4" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.3" + espree "^9.6.1" + esquery "^1.4.2" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.3" + strip-ansi "^6.0.1" + text-table "^0.2.0" + +espree@^9.6.0, espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== + dependencies: + acorn "^8.9.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esquery@^1.4.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== + dependencies: + estraverse "^5.1.0" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^5.1.0, estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + +execa@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + +execa@^7.1.1: + version "7.2.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-7.2.0.tgz#657e75ba984f42a70f38928cedc87d6f2d4fe4e9" + integrity sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.1" + human-signals "^4.3.0" + is-stream "^3.0.0" + merge-stream "^2.0.0" + npm-run-path "^5.1.0" + onetime "^6.0.0" + signal-exit "^3.0.7" + strip-final-newline "^3.0.0" + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ== + +expect@^29.0.0, expect@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-29.7.0.tgz#578874590dcb3214514084c08115d8aee61e11bc" + integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== + dependencies: + "@jest/expect-utils" "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-diff@^1.1.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + +fast-glob@^3.2.12: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-glob@^3.2.9: + version "3.3.1" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4" + integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-glob@^3.3.0: + version "3.3.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" + integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0, fast-json-stable-stringify@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-levenshtein@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== + +fastq@^1.6.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== + dependencies: + reusify "^1.0.4" + +fb-watchman@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" + integrity sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA== + dependencies: + bser "2.1.1" + +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== + dependencies: + flat-cache "^3.0.4" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@^4.0.0, find-up@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +find-up@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== + dependencies: + flatted "^3.1.0" + rimraf "^3.0.2" + +flatted@^3.1.0: + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== + +form-data-encoder@1.7.2: + version "1.7.2" + resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-1.7.2.tgz#1f1ae3dccf58ed4690b86d87e4f57c654fbab040" + integrity sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A== + +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +formdata-node@^4.3.2: + version "4.3.3" + resolved "https://registry.yarnpkg.com/formdata-node/-/formdata-node-4.3.3.tgz#21415225be66e2c87a917bfc0fedab30a119c23c" + integrity sha512-coTew7WODO2vF+XhpUdmYz4UBvlsiTMSNaFYZlrXIqYbFd4W7bMwnoALNLE6uvNgzTg2j1JDF0ZImEfF06VPAA== + dependencies: + node-domexception "1.0.0" + web-streams-polyfill "4.0.0-beta.1" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@^2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +gensync@^1.0.0-beta.2: + version "1.0.0-beta.2" + resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" + integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +get-package-type@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" + integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== + +get-stdin@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53" + integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg== + +get-stream@^6.0.0, get-stream@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + +glob-parent@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-parent@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" + integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== + dependencies: + is-glob "^4.0.3" + +glob@^7.1.3, glob@^7.1.4: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +globals@^11.1.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + +globals@^13.19.0: + version "13.20.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" + integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ== + dependencies: + type-fest "^0.20.2" + +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +graceful-fs@^4.2.9: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" + integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA== + dependencies: + function-bind "^1.1.2" + +html-escaper@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" + integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== + +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + +human-signals@^4.3.0: + version "4.3.1" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-4.3.1.tgz#ab7f811e851fca97ffbd2c1fe9a958964de321b2" + integrity sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ== + +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0= + dependencies: + ms "^2.0.0" + +ignore@^5.2.0, ignore@^5.2.4: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== + +import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +import-local@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" + integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== + dependencies: + pkg-dir "^4.2.0" + resolve-cwd "^3.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + +indent-string@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" + integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== + +is-core-module@^2.13.0: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== + dependencies: + hasown "^2.0.0" + +is-docker@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== + +is-docker@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-3.0.0.tgz#90093aa3106277d8a77a5910dbae71747e15a200" + integrity sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-generator-fn@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" + integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== + +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-inside-container@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" + integrity sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA== + dependencies: + is-docker "^3.0.0" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-path-inside@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" + integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== + +is-stream@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" + integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== + +is-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" + integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== + +is-wsl@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== + dependencies: + is-docker "^2.0.0" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz#2d166c4b0644d43a39f04bf6c2edd1e585f31756" + integrity sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg== + +istanbul-lib-instrument@^5.0.4: + version "5.2.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz#d10c8885c2125574e1c231cacadf955675e1ce3d" + integrity sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg== + dependencies: + "@babel/core" "^7.12.3" + "@babel/parser" "^7.14.7" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-coverage "^3.2.0" + semver "^6.3.0" + +istanbul-lib-instrument@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.1.tgz#71e87707e8041428732518c6fb5211761753fbdf" + integrity sha512-EAMEJBsYuyyztxMxW3g7ugGPkrZsV57v0Hmv3mm1uQsmB+QnZuepg731CRaIgeUVSdmsTngOkSnauNF8p7FIhA== + dependencies: + "@babel/core" "^7.12.3" + "@babel/parser" "^7.14.7" + "@istanbuljs/schema" "^0.1.2" + istanbul-lib-coverage "^3.2.0" + semver "^7.5.4" + +istanbul-lib-report@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" + integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== + dependencies: + istanbul-lib-coverage "^3.0.0" + make-dir "^4.0.0" + supports-color "^7.1.0" + +istanbul-lib-source-maps@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" + integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^3.0.0" + source-map "^0.6.1" + +istanbul-reports@^3.1.3: + version "3.1.6" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.6.tgz#2544bcab4768154281a2f0870471902704ccaa1a" + integrity sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg== + dependencies: + html-escaper "^2.0.0" + istanbul-lib-report "^3.0.0" + +jest-changed-files@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-29.7.0.tgz#1c06d07e77c78e1585d020424dedc10d6e17ac3a" + integrity sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w== + dependencies: + execa "^5.0.0" + jest-util "^29.7.0" + p-limit "^3.1.0" + +jest-circus@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-circus/-/jest-circus-29.7.0.tgz#b6817a45fcc835d8b16d5962d0c026473ee3668a" + integrity sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/expect" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + co "^4.6.0" + dedent "^1.0.0" + is-generator-fn "^2.0.0" + jest-each "^29.7.0" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-runtime "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + p-limit "^3.1.0" + pretty-format "^29.7.0" + pure-rand "^6.0.0" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-cli@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-29.7.0.tgz#5592c940798e0cae677eec169264f2d839a37995" + integrity sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg== + dependencies: + "@jest/core" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + chalk "^4.0.0" + create-jest "^29.7.0" + exit "^0.1.2" + import-local "^3.0.2" + jest-config "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + yargs "^17.3.1" + +jest-config@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-29.7.0.tgz#bcbda8806dbcc01b1e316a46bb74085a84b0245f" + integrity sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ== + dependencies: + "@babel/core" "^7.11.6" + "@jest/test-sequencer" "^29.7.0" + "@jest/types" "^29.6.3" + babel-jest "^29.7.0" + chalk "^4.0.0" + ci-info "^3.2.0" + deepmerge "^4.2.2" + glob "^7.1.3" + graceful-fs "^4.2.9" + jest-circus "^29.7.0" + jest-environment-node "^29.7.0" + jest-get-type "^29.6.3" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-runner "^29.7.0" + jest-util "^29.7.0" + jest-validate "^29.7.0" + micromatch "^4.0.4" + parse-json "^5.2.0" + pretty-format "^29.7.0" + slash "^3.0.0" + strip-json-comments "^3.1.1" + +jest-diff@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.7.0.tgz#017934a66ebb7ecf6f205e84699be10afd70458a" + integrity sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw== + dependencies: + chalk "^4.0.0" + diff-sequences "^29.6.3" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-docblock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-29.7.0.tgz#8fddb6adc3cdc955c93e2a87f61cfd350d5d119a" + integrity sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g== + dependencies: + detect-newline "^3.0.0" + +jest-each@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-29.7.0.tgz#162a9b3f2328bdd991beaabffbb74745e56577d1" + integrity sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ== + dependencies: + "@jest/types" "^29.6.3" + chalk "^4.0.0" + jest-get-type "^29.6.3" + jest-util "^29.7.0" + pretty-format "^29.7.0" + +jest-environment-node@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.7.0.tgz#0b93e111dda8ec120bc8300e6d1fb9576e164376" + integrity sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-mock "^29.7.0" + jest-util "^29.7.0" + +jest-get-type@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.6.3.tgz#36f499fdcea197c1045a127319c0481723908fd1" + integrity sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw== + +jest-haste-map@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-29.7.0.tgz#3c2396524482f5a0506376e6c858c3bbcc17b104" + integrity sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA== + dependencies: + "@jest/types" "^29.6.3" + "@types/graceful-fs" "^4.1.3" + "@types/node" "*" + anymatch "^3.0.3" + fb-watchman "^2.0.0" + graceful-fs "^4.2.9" + jest-regex-util "^29.6.3" + jest-util "^29.7.0" + jest-worker "^29.7.0" + micromatch "^4.0.4" + walker "^1.0.8" + optionalDependencies: + fsevents "^2.3.2" + +jest-leak-detector@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz#5b7ec0dadfdfec0ca383dc9aa016d36b5ea4c728" + integrity sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw== + dependencies: + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-matcher-utils@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz#ae8fec79ff249fd592ce80e3ee474e83a6c44f12" + integrity sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g== + dependencies: + chalk "^4.0.0" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + pretty-format "^29.7.0" + +jest-message-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.7.0.tgz#8bc392e204e95dfe7564abbe72a404e28e51f7f3" + integrity sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w== + dependencies: + "@babel/code-frame" "^7.12.13" + "@jest/types" "^29.6.3" + "@types/stack-utils" "^2.0.0" + chalk "^4.0.0" + graceful-fs "^4.2.9" + micromatch "^4.0.4" + pretty-format "^29.7.0" + slash "^3.0.0" + stack-utils "^2.0.3" + +jest-mock@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.7.0.tgz#4e836cf60e99c6fcfabe9f99d017f3fdd50a6347" + integrity sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + jest-util "^29.7.0" + +jest-pnp-resolver@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz#930b1546164d4ad5937d5540e711d4d38d4cad2e" + integrity sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w== + +jest-regex-util@^29.6.3: + version "29.6.3" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-29.6.3.tgz#4a556d9c776af68e1c5f48194f4d0327d24e8a52" + integrity sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg== + +jest-resolve-dependencies@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz#1b04f2c095f37fc776ff40803dc92921b1e88428" + integrity sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA== + dependencies: + jest-regex-util "^29.6.3" + jest-snapshot "^29.7.0" + +jest-resolve@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-29.7.0.tgz#64d6a8992dd26f635ab0c01e5eef4399c6bcbc30" + integrity sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA== + dependencies: + chalk "^4.0.0" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-pnp-resolver "^1.2.2" + jest-util "^29.7.0" + jest-validate "^29.7.0" + resolve "^1.20.0" + resolve.exports "^2.0.0" + slash "^3.0.0" + +jest-runner@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-29.7.0.tgz#809af072d408a53dcfd2e849a4c976d3132f718e" + integrity sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ== + dependencies: + "@jest/console" "^29.7.0" + "@jest/environment" "^29.7.0" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + emittery "^0.13.1" + graceful-fs "^4.2.9" + jest-docblock "^29.7.0" + jest-environment-node "^29.7.0" + jest-haste-map "^29.7.0" + jest-leak-detector "^29.7.0" + jest-message-util "^29.7.0" + jest-resolve "^29.7.0" + jest-runtime "^29.7.0" + jest-util "^29.7.0" + jest-watcher "^29.7.0" + jest-worker "^29.7.0" + p-limit "^3.1.0" + source-map-support "0.5.13" + +jest-runtime@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-29.7.0.tgz#efecb3141cf7d3767a3a0cc8f7c9990587d3d817" + integrity sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ== + dependencies: + "@jest/environment" "^29.7.0" + "@jest/fake-timers" "^29.7.0" + "@jest/globals" "^29.7.0" + "@jest/source-map" "^29.6.3" + "@jest/test-result" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + cjs-module-lexer "^1.0.0" + collect-v8-coverage "^1.0.0" + glob "^7.1.3" + graceful-fs "^4.2.9" + jest-haste-map "^29.7.0" + jest-message-util "^29.7.0" + jest-mock "^29.7.0" + jest-regex-util "^29.6.3" + jest-resolve "^29.7.0" + jest-snapshot "^29.7.0" + jest-util "^29.7.0" + slash "^3.0.0" + strip-bom "^4.0.0" + +jest-snapshot@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-29.7.0.tgz#c2c574c3f51865da1bb329036778a69bf88a6be5" + integrity sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw== + dependencies: + "@babel/core" "^7.11.6" + "@babel/generator" "^7.7.2" + "@babel/plugin-syntax-jsx" "^7.7.2" + "@babel/plugin-syntax-typescript" "^7.7.2" + "@babel/types" "^7.3.3" + "@jest/expect-utils" "^29.7.0" + "@jest/transform" "^29.7.0" + "@jest/types" "^29.6.3" + babel-preset-current-node-syntax "^1.0.0" + chalk "^4.0.0" + expect "^29.7.0" + graceful-fs "^4.2.9" + jest-diff "^29.7.0" + jest-get-type "^29.6.3" + jest-matcher-utils "^29.7.0" + jest-message-util "^29.7.0" + jest-util "^29.7.0" + natural-compare "^1.4.0" + pretty-format "^29.7.0" + semver "^7.5.3" + +jest-util@^29.0.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== + dependencies: + "@jest/types" "^29.6.3" + "@types/node" "*" + chalk "^4.0.0" + ci-info "^3.2.0" + graceful-fs "^4.2.9" + picomatch "^2.2.3" + +jest-validate@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-29.7.0.tgz#7bf705511c64da591d46b15fce41400d52147d9c" + integrity sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw== + dependencies: + "@jest/types" "^29.6.3" + camelcase "^6.2.0" + chalk "^4.0.0" + jest-get-type "^29.6.3" + leven "^3.1.0" + pretty-format "^29.7.0" + +jest-watcher@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-29.7.0.tgz#7810d30d619c3a62093223ce6bb359ca1b28a2f2" + integrity sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g== + dependencies: + "@jest/test-result" "^29.7.0" + "@jest/types" "^29.6.3" + "@types/node" "*" + ansi-escapes "^4.2.1" + chalk "^4.0.0" + emittery "^0.13.1" + jest-util "^29.7.0" + string-length "^4.0.1" + +jest-worker@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.7.0.tgz#acad073acbbaeb7262bd5389e1bcf43e10058d4a" + integrity sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw== + dependencies: + "@types/node" "*" + jest-util "^29.7.0" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +jest@^29.4.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-29.7.0.tgz#994676fc24177f088f1c5e3737f5697204ff2613" + integrity sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw== + dependencies: + "@jest/core" "^29.7.0" + "@jest/types" "^29.6.3" + import-local "^3.0.2" + jest-cli "^29.7.0" + +js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +jsesc@^2.5.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" + integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== + +json-parse-even-better-errors@^2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== + +json5@^2.2.2, json5@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== + +jsonc-parser@^3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.1.tgz#031904571ccf929d7670ee8c547545081cb37f1a" + integrity sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA== + +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + +leven@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" + integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== + +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +lines-and-columns@^1.1.6: + version "1.2.4" + resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" + integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.memoize@4.x: + version "4.1.2" + resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" + integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag== + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +make-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" + integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== + dependencies: + semver "^7.5.3" + +make-error@1.x, make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +makeerror@1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a" + integrity sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg== + dependencies: + tmpl "1.0.5" + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +mime-db@1.51.0: + version "1.51.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" + integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== + +mime-types@^2.1.12: + version "2.1.34" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" + integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== + dependencies: + mime-db "1.51.0" + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +mimic-fn@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc" + integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw== + +minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^7.4.3: + version "7.4.6" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-7.4.6.tgz#845d6f254d8f4a5e4fd6baf44d5f10c8448365fb" + integrity sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw== + dependencies: + brace-expansion "^2.0.1" + +minimist@^1.2.6: + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== + +mkdirp@^2.1.6: + version "2.1.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" + integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@^2.0.0: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +node-domexception@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" + integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== + +node-fetch@^2.6.7: + version "2.6.11" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.11.tgz#cde7fc71deef3131ef80a738919f999e6edfff25" + integrity sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w== + dependencies: + whatwg-url "^5.0.0" + +node-int64@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" + integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== + +node-releases@^2.0.14: + version "2.0.14" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" + integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== + +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + dependencies: + path-key "^3.0.0" + +npm-run-path@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-5.1.0.tgz#bc62f7f3f6952d9894bd08944ba011a6ee7b7e00" + integrity sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q== + dependencies: + path-key "^4.0.0" + +object-inspect@^1.13.1: + version "1.13.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" + integrity sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +onetime@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-6.0.0.tgz#7c24c18ed1fd2e9bca4bd26806a33613c77d34b4" + integrity sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ== + dependencies: + mimic-fn "^4.0.0" + +open@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/open/-/open-9.1.0.tgz#684934359c90ad25742f5a26151970ff8c6c80b6" + integrity sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg== + dependencies: + default-browser "^4.0.0" + define-lazy-prop "^3.0.0" + is-inside-container "^1.0.0" + is-wsl "^2.2.0" + +optionator@^0.9.3: + version "0.9.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" + integrity sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg== + dependencies: + "@aashutoshrathi/word-wrap" "^1.2.3" + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + +p-all@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-all/-/p-all-3.0.0.tgz#077c023c37e75e760193badab2bad3ccd5782bfb" + integrity sha512-qUZbvbBFVXm6uJ7U/WDiO0fv6waBMbjlCm4E66oZdRR+egswICarIdHyVSZZHudH8T5SF8x/JG0q0duFzPnlBw== + dependencies: + p-map "^4.0.0" + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2, p-limit@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-map@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== + dependencies: + aggregate-error "^3.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +parse-json@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" + integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== + dependencies: + "@babel/code-frame" "^7.0.0" + error-ex "^1.3.1" + json-parse-even-better-errors "^2.3.0" + lines-and-columns "^1.1.6" + +path-browserify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.0.0, path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-key@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-4.0.0.tgz#295588dc3aee64154f877adb9d780b81c554bf18" + integrity sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-type@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== + +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pirates@^4.0.4: + version "4.0.6" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9" + integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg== + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" + integrity sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw== + +pretty-format@^29.0.0, pretty-format@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812" + integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ== + dependencies: + "@jest/schemas" "^29.6.3" + ansi-styles "^5.0.0" + react-is "^18.0.0" + +prompts@^2.0.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + +punycode@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== + +pure-rand@^6.0.0: + version "6.0.4" + resolved "https://registry.yarnpkg.com/pure-rand/-/pure-rand-6.0.4.tgz#50b737f6a925468679bff00ad20eade53f37d5c7" + integrity sha512-LA0Y9kxMYv47GIPJy6MI84fqTd2HmYZI83W/kM/SkKfDlajnZYfmXFTxkbY+xSBPkLJxltMa9hIkmdc29eguMA== + +qs@^6.10.3: + version "6.12.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.12.3.tgz#e43ce03c8521b9c7fd7f1f13e514e5ca37727754" + integrity sha512-AWJm14H1vVaO/iNZ4/hO+HyaTehuy9nRqVdkTqlJt0HWvBiBIEXFmb4C0DGeYo3Xes9rrEW+TxHsaigCbN5ICQ== + dependencies: + side-channel "^1.0.6" + +queue-microtask@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +react-is@^18.0.0: + version "18.2.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" + integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== + +readable-stream@^3.4.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +resolve-cwd@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== + dependencies: + resolve-from "^5.0.0" + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + +resolve.exports@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-2.0.2.tgz#f8c934b8e6a13f539e38b7098e2e36134f01e800" + integrity sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg== + +resolve@^1.20.0: + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +run-applescript@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-5.0.0.tgz#e11e1c932e055d5c6b40d98374e0268d9b11899c" + integrity sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg== + dependencies: + execa "^5.0.0" + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.5.3, semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +side-channel@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + +signal-exit@^3.0.3, signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + +source-map-support@0.5.13: + version "0.5.13" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" + integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +stack-utils@^2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" + integrity sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ== + dependencies: + escape-string-regexp "^2.0.0" + +string-length@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a" + integrity sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ== + dependencies: + char-regex "^1.0.2" + strip-ansi "^6.0.0" + +string-to-stream@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/string-to-stream/-/string-to-stream-3.0.1.tgz#480e6fb4d5476d31cb2221f75307a5dcb6638a42" + integrity sha512-Hl092MV3USJuUCC6mfl9sPzGloA3K5VwdIeJjYIkXY/8K+mUvaeEabWJgArp+xXrsWxCajeT2pc4axbVhIZJyg== + dependencies: + readable-stream "^3.4.0" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + +strip-bom@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" + integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== + +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== + +strip-final-newline@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" + integrity sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw== + +strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +superstruct@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-1.0.3.tgz#de626a5b49c6641ff4d37da3c7598e7a87697046" + integrity sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg== + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +synckit@^0.8.5: + version "0.8.6" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.6.tgz#b69b7fbce3917c2673cbdc0d87fb324db4a5b409" + integrity sha512-laHF2savN6sMeHCjLRkheIU4wo3Zg9Ln5YOjOo7sZ5dVQW8yF5pPE5SIw1dsPhq3TRp1jisKRCdPhfs/1WMqDA== + dependencies: + "@pkgr/utils" "^2.4.2" + tslib "^2.6.2" + +test-exclude@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" + integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w== + dependencies: + "@istanbuljs/schema" "^0.1.2" + glob "^7.1.4" + minimatch "^3.0.4" + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== + +titleize@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53" + integrity sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ== + +tmpl@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" + integrity sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw== + +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= + +ts-api-utils@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.3.tgz#f12c1c781d04427313dbac808f453f050e54a331" + integrity sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg== + +ts-jest@^29.1.0: + version "29.1.1" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.1.1.tgz#f58fe62c63caf7bfcc5cc6472082f79180f0815b" + integrity sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA== + dependencies: + bs-logger "0.x" + fast-json-stable-stringify "2.x" + jest-util "^29.0.0" + json5 "^2.2.3" + lodash.memoize "4.x" + make-error "1.x" + semver "^7.5.3" + yargs-parser "^21.0.1" + +ts-morph@^19.0.0: + version "19.0.0" + resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-19.0.0.tgz#43e95fb0156c3fe3c77c814ac26b7d0be2f93169" + integrity sha512-D6qcpiJdn46tUqV45vr5UGM2dnIEuTGNxVhg0sk5NX11orcouwj6i1bMqZIz2mZTZB1Hcgy7C3oEVhAT+f6mbQ== + dependencies: + "@ts-morph/common" "~0.20.0" + code-block-writer "^12.0.0" + +ts-node@^10.5.0: + version "10.7.0" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5" + integrity sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A== + dependencies: + "@cspotcode/source-map-support" "0.7.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.0" + yn "3.1.1" + +tsc-multi@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/tsc-multi/-/tsc-multi-1.1.0.tgz#0e2b03c0ed0ac58ecb556f11709441102d202680" + integrity sha512-THE6X+sse7EZ2qMhqXvBhd2HMTvXyWwYnx+2T/ijqdp/6Rf7rUc2uPRzPdrrljZCNcYDeL0qP2P7tqm2IwayTg== + dependencies: + debug "^4.3.4" + fast-glob "^3.2.12" + get-stdin "^8.0.0" + p-all "^3.0.0" + picocolors "^1.0.0" + signal-exit "^3.0.7" + string-to-stream "^3.0.1" + superstruct "^1.0.3" + tslib "^2.5.0" + yargs "^17.7.1" + +tsconfig-paths@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz#ef78e19039133446d244beac0fd6a1632e2d107c" + integrity sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg== + dependencies: + json5 "^2.2.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + +tslib@^2.5.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" + integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== + +tslib@^2.6.0, tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + +type-detect@4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +typescript@^4.8.2: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +untildify@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" + integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== + +update-browserslist-db@^1.0.13: + version "1.0.13" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" + integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +util-deprecate@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +v8-compile-cache-lib@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8" + integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA== + +v8-to-istanbul@^9.0.1: + version "9.2.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz#2ed7644a245cddd83d4e087b9b33b3e62dfd10ad" + integrity sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA== + dependencies: + "@jridgewell/trace-mapping" "^0.3.12" + "@types/istanbul-lib-coverage" "^2.0.1" + convert-source-map "^2.0.0" + +walker@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.8.tgz#bd498db477afe573dc04185f011d3ab8a8d7653f" + integrity sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ== + dependencies: + makeerror "1.0.12" + +web-streams-polyfill@4.0.0-beta.1: + version "4.0.0-beta.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.1.tgz#3b19b9817374b7cee06d374ba7eeb3aeb80e8c95" + integrity sha512-3ux37gEX670UUphBF9AMCq8XM6iQ8Ac6A+DSRRjDoRBm1ufCkaCDdNVbaqq60PsEkdNlLKrGtv/YBP4EJXqNtQ== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +write-file-atomic@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-4.0.2.tgz#a9df01ae5b77858a027fd2e80768ee433555fcfd" + integrity sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg== + dependencies: + imurmurhash "^0.1.4" + signal-exit "^3.0.7" + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@^21.0.1, yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + +yargs@^17.3.1, yargs@^17.7.1: + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== + dependencies: + cliui "^8.0.1" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.3" + y18n "^5.0.5" + yargs-parser "^21.1.1" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==