From 8f7c33ec5336b8750e0598b1691aa9a6d510ad93 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 16:19:53 +0100 Subject: [PATCH] release: 6.0.0-beta.2 (#427) * feat(api): update via SDK Studio (#426) * chore(tests): update prism version (#428) * feat(api): update via SDK Studio (#429) * chore(tests): update prism version (#430) * fix(compat): remove ReadableStream polyfill redundant since node v16 (#431) Note that this breaks streaming in Node v14, which has been unsupported since v4.0.0 of this library. * chore(internal): codegen related update (#432) * chore(docs): fix incorrect client var names (#433) * chore(internal): add constant for default timeout (#434) * feat(api): update via SDK Studio (#435) * release: 6.0.0-beta.2 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- .stats.yml | 2 +- CHANGELOG.md | 24 +++++++++ README.md | 16 +++--- api.md | 17 +++--- package.json | 5 +- scripts/mock | 4 +- src/_shims/node-runtime.ts | 4 +- src/index.ts | 5 +- src/resources/conversations/conversations.ts | 29 ++++++----- src/resources/conversations/index.ts | 2 +- src/resources/index.ts | 2 +- src/resources/news/index.ts | 9 +++- src/resources/news/news-items.ts | 36 +++++++++++-- src/resources/news/news.ts | 2 + src/resources/news/newsfeeds/index.ts | 10 +++- src/resources/news/newsfeeds/items.ts | 41 ++++++++++++--- src/resources/news/newsfeeds/newsfeeds.ts | 37 +++++++++++-- src/resources/shared.ts | 30 ----------- src/version.ts | 2 +- .../admins/activity-logs.test.ts | 6 +-- tests/api-resources/admins/admins.test.ts | 18 +++---- tests/api-resources/articles.test.ts | 39 +++++++------- .../api-resources/companies/companies.test.ts | 46 ++++++++-------- .../api-resources/companies/contacts.test.ts | 8 +-- .../api-resources/companies/segments.test.ts | 8 +-- .../api-resources/contacts/companies.test.ts | 20 +++---- tests/api-resources/contacts/contacts.test.ts | 52 +++++++++---------- tests/api-resources/contacts/notes.test.ts | 12 ++--- tests/api-resources/contacts/segments.test.ts | 8 +-- .../contacts/subscriptions.test.ts | 18 +++---- tests/api-resources/contacts/tags.test.ts | 18 +++---- .../conversations/conversations.test.ts | 36 ++++++------- .../conversations/customers.test.ts | 12 ++--- .../api-resources/conversations/parts.test.ts | 6 +-- .../api-resources/conversations/reply.test.ts | 6 +-- .../run-assignment-rules.test.ts | 8 +-- .../api-resources/conversations/tags.test.ts | 10 ++-- tests/api-resources/data-attributes.test.ts | 18 +++---- tests/api-resources/data-events.test.ts | 16 +++--- tests/api-resources/data-exports.test.ts | 6 +-- .../download/content/data.test.ts | 8 +-- .../api-resources/export/content/data.test.ts | 8 +-- tests/api-resources/export/export.test.ts | 8 +-- .../help-center/collections.test.ts | 30 +++++------ .../help-center/help-centers.test.ts | 14 ++--- tests/api-resources/me.test.ts | 8 +-- tests/api-resources/messages.test.ts | 6 +-- tests/api-resources/news/news-items.test.ts | 32 +++++------- .../news/newsfeeds/items.test.ts | 8 +-- .../news/newsfeeds/newsfeeds.test.ts | 18 +++---- tests/api-resources/notes.test.ts | 8 +-- .../phone-call-redirects.test.ts | 6 +-- tests/api-resources/segments.test.ts | 14 ++--- .../api-resources/subscription-types.test.ts | 8 +-- tests/api-resources/tags.test.ts | 24 ++++----- tests/api-resources/teams.test.ts | 14 ++--- .../ticket-types/attributes.test.ts | 12 ++--- .../ticket-types/ticket-types.test.ts | 28 +++++----- tests/api-resources/tickets/tags.test.ts | 15 ++---- tests/api-resources/tickets/tickets.test.ts | 30 +++++------ tests/api-resources/visitors.test.ts | 14 ++--- yarn.lock | 5 -- 63 files changed, 522 insertions(+), 446 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d41bd0f1..5ed3743d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "6.0.0-beta.1" + ".": "6.0.0-beta.2" } diff --git a/.stats.yml b/.stats.yml index 75bc5ebf..d3cca5f0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 108 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-61fd2f21fb0fb6a94c5e87ea423d828bf37d1dd90ca1511eda9b91d58ccb5d39.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a52cc0e4313a38d4329e6c2f40afa341d800389762fc643b9bf5b13248f8c5da.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 178afe6b..0865bd1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## 6.0.0-beta.2 (2024-07-30) + +Full Changelog: [v6.0.0-beta.1...v6.0.0-beta.2](https://github.com/intercom/intercom-node/compare/v6.0.0-beta.1...v6.0.0-beta.2) + +### Features + +* **api:** update via SDK Studio ([#426](https://github.com/intercom/intercom-node/issues/426)) ([ef7e2da](https://github.com/intercom/intercom-node/commit/ef7e2da5db3c43bc5c418d2d225152824f1fee98)) +* **api:** update via SDK Studio ([#429](https://github.com/intercom/intercom-node/issues/429)) ([87e2fc5](https://github.com/intercom/intercom-node/commit/87e2fc5a69de4ff9cbcd965dee87c116ffa0351c)) +* **api:** update via SDK Studio ([#435](https://github.com/intercom/intercom-node/issues/435)) ([00dfaa7](https://github.com/intercom/intercom-node/commit/00dfaa769e2e82e30824b7530fb10dca0074a29e)) + + +### Bug Fixes + +* **compat:** remove ReadableStream polyfill redundant since node v16 ([#431](https://github.com/intercom/intercom-node/issues/431)) ([063c487](https://github.com/intercom/intercom-node/commit/063c487e24daafd0c062ebf76802c4a63e0e81b8)) + + +### Chores + +* **docs:** fix incorrect client var names ([#433](https://github.com/intercom/intercom-node/issues/433)) ([4a0ad83](https://github.com/intercom/intercom-node/commit/4a0ad830f2f68faa88aaa614e625776a19310092)) +* **internal:** add constant for default timeout ([#434](https://github.com/intercom/intercom-node/issues/434)) ([0a41a59](https://github.com/intercom/intercom-node/commit/0a41a59c08f3c3225113464ee1fa336179e740c9)) +* **internal:** codegen related update ([#432](https://github.com/intercom/intercom-node/issues/432)) ([c76e487](https://github.com/intercom/intercom-node/commit/c76e48745a679b3155c22736e14b61af6df8aaf4)) +* **tests:** update prism version ([#428](https://github.com/intercom/intercom-node/issues/428)) ([425939f](https://github.com/intercom/intercom-node/commit/425939f4145d533621e53c36b786caebb8a1932f)) +* **tests:** update prism version ([#430](https://github.com/intercom/intercom-node/issues/430)) ([d123ec9](https://github.com/intercom/intercom-node/commit/d123ec9ea199e56b76f8ae9cc9f4cc31318659f8)) + ## 6.0.0-beta.1 (2024-07-19) Full Changelog: [v6.0.0-beta.0...v6.0.0-beta.1](https://github.com/intercom/intercom-node/compare/v6.0.0-beta.0...v6.0.0-beta.1) diff --git a/README.md b/README.md index fa0ca9be..73645c53 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ const client = new Intercom({ }); async function main() { - const adminWithApp = await intercom.me.retrieve(); + const adminWithApp = await client.me.retrieve(); console.log(adminWithApp.id); } @@ -50,7 +50,7 @@ const client = new Intercom({ }); async function main() { - const adminWithApp: Intercom.AdminWithApp | null = await intercom.me.retrieve(); + const adminWithApp: Intercom.AdminWithApp | null = await client.me.retrieve(); } main(); @@ -67,7 +67,7 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const adminWithApp = await intercom.me.retrieve().catch(async (err) => { + const adminWithApp = await client.me.retrieve().catch(async (err) => { if (err instanceof Intercom.APIError) { console.log(err.status); // 400 console.log(err.name); // BadRequestError @@ -110,7 +110,7 @@ const client = new Intercom({ }); // Or, configure per-request: -await intercom.me.retrieve({ +await client.me.retrieve({ maxRetries: 5, }); ``` @@ -127,7 +127,7 @@ const client = new Intercom({ }); // Override per-request: -await intercom.me.retrieve({ +await client.me.retrieve({ timeout: 5 * 1000, }); ``` @@ -148,11 +148,11 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts const client = new Intercom(); -const response = await intercom.me.retrieve().asResponse(); +const response = await client.me.retrieve().asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object -const { data: adminWithApp, response: raw } = await intercom.me.retrieve().withResponse(); +const { data: adminWithApp, response: raw } = await client.me.retrieve().withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(adminWithApp.id); ``` @@ -258,7 +258,7 @@ const client = new Intercom({ }); // Override per-request: -await intercom.me.retrieve({ +await client.me.retrieve({ httpAgent: new http.Agent({ keepAlive: false }), }); ``` diff --git a/api.md b/api.md index 94e628d1..8acece46 100644 --- a/api.md +++ b/api.md @@ -15,7 +15,6 @@ Types: - Message - MultipleFilterSearchRequest - Note -- PaginatedResponse - PartAttachment - Reference - SearchRequest @@ -223,8 +222,8 @@ Methods: Types: -- ConversationList - ConversationListResponse +- ConversationSearchResponse Methods: @@ -234,7 +233,7 @@ Methods: - client.conversations.list({ ...params }) -> ConversationListResponsesCursorPagination - client.conversations.convert(id, { ...params }) -> Ticket | null - client.conversations.redact({ ...params }) -> Conversation -- client.conversations.search({ ...params }) -> ConversationList +- client.conversations.search({ ...params }) -> ConversationSearchResponse ## Tags @@ -340,6 +339,7 @@ Methods: Types: - NewsItem +- NewsItemListResponse - NewsItemDeleteResponse Methods: @@ -347,7 +347,7 @@ 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 }) -> PaginatedResponse +- client.news.newsItems.list({ ...params }) -> NewsItemListResponse - client.news.newsItems.delete(id, { ...params }) -> NewsItemDeleteResponse ## Newsfeeds @@ -355,17 +355,22 @@ Methods: Types: - Newsfeed +- NewsfeedListResponse Methods: - client.news.newsfeeds.retrieve(id, { ...params }) -> Newsfeed -- client.news.newsfeeds.list({ ...params }) -> PaginatedResponse +- client.news.newsfeeds.list({ ...params }) -> NewsfeedListResponse ### Items +Types: + +- ItemListResponse + Methods: -- client.news.newsfeeds.items.list(id, { ...params }) -> PaginatedResponse +- client.news.newsfeeds.items.list(id, { ...params }) -> ItemListResponse # Notes diff --git a/package.json b/package.json index 68b8c7ef..18630442 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intercom-client", - "version": "6.0.0-beta.1", + "version": "6.0.0-beta.2", "description": "The official TypeScript library for the Intercom API", "author": "Intercom ", "types": "dist/index.d.ts", @@ -32,8 +32,7 @@ "form-data-encoder": "1.7.2", "formdata-node": "^4.3.2", "node-fetch": "^2.6.7", - "qs": "^6.10.3", - "web-streams-polyfill": "^3.2.1" + "qs": "^6.10.3" }, "devDependencies": { "@swc/core": "^1.3.102", diff --git a/scripts/mock b/scripts/mock index fe89a1d0..f5861576 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & + 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" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" fi diff --git a/src/_shims/node-runtime.ts b/src/_shims/node-runtime.ts index a9c42ebe..ab9f2ab5 100644 --- a/src/_shims/node-runtime.ts +++ b/src/_shims/node-runtime.ts @@ -13,9 +13,7 @@ import { Readable } from 'node:stream'; import { type RequestOptions } from '../core'; import { MultipartBody } from './MultipartBody'; import { type Shims } from './registry'; - -// @ts-ignore (this package does not have proper export maps for this export) -import { ReadableStream } from 'web-streams-polyfill/dist/ponyfill.es2018.js'; +import { ReadableStream } from 'node:stream/web'; type FileFromPathOptions = Omit; diff --git a/src/index.ts b/src/index.ts index f47abf32..fec3f739 100644 --- a/src/index.ts +++ b/src/index.ts @@ -190,6 +190,7 @@ export class Intercom extends Core.APIClient { } static Intercom = this; + static DEFAULT_TIMEOUT = 60000; // 1 minute static IntercomError = Errors.IntercomError; static APIError = Errors.APIError; @@ -289,8 +290,9 @@ export namespace Intercom { export import ContactUnarchiveParams = API.ContactUnarchiveParams; export import Conversations = API.Conversations; - export import ConversationList = API.ConversationList; 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; @@ -391,7 +393,6 @@ export namespace Intercom { export import Message = API.Message; export import MultipleFilterSearchRequest = API.MultipleFilterSearchRequest; export import Note = API.Note; - export import PaginatedResponse = API.PaginatedResponse; export import PartAttachment = API.PartAttachment; export import Reference = API.Reference; export import SearchRequest = API.SearchRequest; diff --git a/src/resources/conversations/conversations.ts b/src/resources/conversations/conversations.ts index 8473d24a..7c189a15 100644 --- a/src/resources/conversations/conversations.ts +++ b/src/resources/conversations/conversations.ts @@ -5,7 +5,6 @@ import { isRequestOptions } from '../../core'; import * as Core from '../../core'; import * as ConversationsAPI from './conversations'; import * as Shared from '../shared'; -import { ConversationListResponsesCursorPagination } from '../shared'; import * as CustomersAPI from './customers'; import * as PartsAPI from './parts'; import * as ReplyAPI from './reply'; @@ -13,7 +12,7 @@ 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 { type CursorPaginationParams } from '../../pagination'; +import { CursorPagination, type CursorPaginationParams } from '../../pagination'; export class Conversations extends APIResource { tags: TagsAPI.Tags = new TagsAPI.Tags(this._client); @@ -324,7 +323,10 @@ export class Conversations extends APIResource { * | ^ | String | Starts With | * | $ | String | Ends With | */ - search(params: ConversationSearchParams, options?: Core.RequestOptions): Core.APIPromise { + search( + params: ConversationSearchParams, + options?: Core.RequestOptions, + ): Core.APIPromise { const { 'Intercom-Version': intercomVersion, ...body } = params; return this._client.post('/conversations/search', { body, @@ -339,12 +341,20 @@ export class Conversations extends APIResource { } } +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 ConversationList { +export interface ConversationSearchResponse { /** * The list of conversation objects */ @@ -369,12 +379,6 @@ export interface ConversationList { type?: 'conversation.list'; } -/** - * 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; - export interface ConversationCreateParams { /** * Body param: The content of the message. HTML is not supported. @@ -725,8 +729,9 @@ export interface ConversationSearchParams { } export namespace Conversations { - export import ConversationList = ConversationsAPI.ConversationList; 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; @@ -747,5 +752,3 @@ export namespace Conversations { export import CustomerCreateParams = CustomersAPI.CustomerCreateParams; export import CustomerDeleteParams = CustomersAPI.CustomerDeleteParams; } - -export { ConversationListResponsesCursorPagination }; diff --git a/src/resources/conversations/index.ts b/src/resources/conversations/index.ts index 780aa261..c68bbad1 100644 --- a/src/resources/conversations/index.ts +++ b/src/resources/conversations/index.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { - ConversationList, ConversationListResponse, + ConversationSearchResponse, ConversationCreateParams, ConversationRetrieveParams, ConversationUpdateParams, diff --git a/src/resources/index.ts b/src/resources/index.ts index c0a4cd09..40a10ea9 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -46,8 +46,8 @@ export { Contacts, } from './contacts/contacts'; export { - ConversationList, ConversationListResponse, + ConversationSearchResponse, ConversationCreateParams, ConversationRetrieveParams, ConversationUpdateParams, diff --git a/src/resources/news/index.ts b/src/resources/news/index.ts index 28fb5254..1f665092 100644 --- a/src/resources/news/index.ts +++ b/src/resources/news/index.ts @@ -3,6 +3,7 @@ export { News } from './news'; export { NewsItem, + NewsItemListResponse, NewsItemDeleteResponse, NewsItemCreateParams, NewsItemRetrieveParams, @@ -11,4 +12,10 @@ export { NewsItemDeleteParams, NewsItems, } from './news-items'; -export { Newsfeed, NewsfeedRetrieveParams, NewsfeedListParams, Newsfeeds } from './newsfeeds/index'; +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 index ff1b642b..ab6635b9 100644 --- a/src/resources/news/news-items.ts +++ b/src/resources/news/news-items.ts @@ -5,6 +5,7 @@ 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 { /** @@ -73,12 +74,12 @@ export class NewsItems extends APIResource { /** * 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, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; list( params: NewsItemListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { if (isRequestOptions(params)) { return this.list({}, params); } @@ -224,6 +225,34 @@ export namespace NewsItem { } } +/** + * 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 */ @@ -506,6 +535,7 @@ export interface NewsItemDeleteParams { 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; diff --git a/src/resources/news/news.ts b/src/resources/news/news.ts index 4e08ea1d..bb45b9e1 100644 --- a/src/resources/news/news.ts +++ b/src/resources/news/news.ts @@ -12,6 +12,7 @@ export class News extends APIResource { 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; @@ -20,6 +21,7 @@ export namespace News { 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 index 060cd639..b88068f0 100644 --- a/src/resources/news/newsfeeds/index.ts +++ b/src/resources/news/newsfeeds/index.ts @@ -1,4 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { ItemListParams, Items } from './items'; -export { Newsfeed, NewsfeedRetrieveParams, NewsfeedListParams, Newsfeeds } from './newsfeeds'; +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 index 8af3ffb4..95904b2c 100644 --- a/src/resources/news/newsfeeds/items.ts +++ b/src/resources/news/newsfeeds/items.ts @@ -5,22 +5,20 @@ 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, 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 { + ): Core.APIPromise { if (isRequestOptions(params)) { return this.list(id, {}, params); } @@ -37,6 +35,34 @@ export class Items extends APIResource { } } +/** + * 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 @@ -64,5 +90,6 @@ export interface ItemListParams { } 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 index 9445db6b..5a762628 100644 --- a/src/resources/news/newsfeeds/newsfeeds.ts +++ b/src/resources/news/newsfeeds/newsfeeds.ts @@ -5,6 +5,7 @@ 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 { @@ -42,12 +43,12 @@ export class Newsfeeds extends APIResource { /** * 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, options?: Core.RequestOptions): Core.APIPromise; + list(options?: Core.RequestOptions): Core.APIPromise; list( params: NewsfeedListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { if (isRequestOptions(params)) { return this.list({}, params); } @@ -98,6 +99,34 @@ export interface Newsfeed { 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 @@ -152,8 +181,10 @@ export interface NewsfeedListParams { 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/shared.ts b/src/resources/shared.ts index 34513059..f7886b44 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -3,9 +3,7 @@ import * as Shared from './shared'; import * as SegmentsAPI from './segments'; import * as SubscriptionsAPI from './contacts/subscriptions'; -import * as NewsItemsAPI from './news/news-items'; import * as TicketTypesAPI from './ticket-types/ticket-types'; -import * as NewsfeedsAPI from './news/newsfeeds/newsfeeds'; /** * Admins are teammate accounts that have access to a workspace. @@ -2034,34 +2032,6 @@ export namespace Note { } } -/** - * Paginated Response - */ -export interface PaginatedResponse { - /** - * 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?: CursorPages | null; - - /** - * A count of the total number of objects. - */ - total_count?: number; - - /** - * The type of object - */ - type?: 'list' | 'conversation.list'; -} - /** * The file attached to a part */ diff --git a/src/version.ts b/src/version.ts index 7057947b..040a9049 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '6.0.0-beta.1'; // x-release-please-version +export const VERSION = '6.0.0-beta.2'; // x-release-please-version diff --git a/tests/api-resources/admins/activity-logs.test.ts b/tests/api-resources/admins/activity-logs.test.ts index e2e84223..3a4c4a36 100644 --- a/tests/api-resources/admins/activity-logs.test.ts +++ b/tests/api-resources/admins/activity-logs.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.admins.activityLogs.list({ created_at_after: 'created_at_after' }); + 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; @@ -21,7 +21,7 @@ describe('resource activityLogs', () => { }); test('list: required and optional params', async () => { - const response = await intercom.admins.activityLogs.list({ + 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 index 56f307c5..43e3105a 100644 --- a/tests/api-resources/admins/admins.test.ts +++ b/tests/api-resources/admins/admins.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.admins.retrieve(123); + const responsePromise = client.admins.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource admins', () => { 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(intercom.admins.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.admins.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,12 +30,12 @@ describe('resource admins', () => { 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( - intercom.admins.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.admins.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('list', async () => { - const responsePromise = intercom.admins.list(); + const responsePromise = client.admins.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -47,7 +47,7 @@ describe('resource admins', () => { 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(intercom.admins.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.admins.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -55,12 +55,12 @@ describe('resource admins', () => { 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( - intercom.admins.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.admins.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('setAway: only required params', async () => { - const responsePromise = intercom.admins.setAway(0, { away_mode_enabled: true, away_mode_reassign: true }); + 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; @@ -71,7 +71,7 @@ describe('resource admins', () => { }); test('setAway: required and optional params', async () => { - const response = await intercom.admins.setAway(0, { + 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 index 2b47337a..75a4dca2 100644 --- a/tests/api-resources/articles.test.ts +++ b/tests/api-resources/articles.test.ts @@ -3,17 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.articles.create({ - author_id: 991268363, - title: 'Thanks for everything', - }); + 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; @@ -24,7 +21,7 @@ describe('resource articles', () => { }); test('create: required and optional params', async () => { - const response = await intercom.articles.create({ + const response = await client.articles.create({ author_id: 991268363, title: 'Thanks for everything', body: 'Body of the Article', @@ -447,7 +444,7 @@ describe('resource articles', () => { }); test('retrieve', async () => { - const responsePromise = intercom.articles.retrieve(123); + const responsePromise = client.articles.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -459,7 +456,7 @@ describe('resource articles', () => { 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(intercom.articles.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.articles.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -467,12 +464,12 @@ describe('resource articles', () => { 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( - intercom.articles.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.articles.retrieve(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('update', async () => { - const responsePromise = intercom.articles.update(123); + const responsePromise = client.articles.update(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -484,7 +481,7 @@ describe('resource articles', () => { 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(intercom.articles.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.articles.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -492,7 +489,7 @@ describe('resource articles', () => { 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( - intercom.articles.update( + client.articles.update( 123, { author_id: 1295, @@ -920,7 +917,7 @@ describe('resource articles', () => { }); test('list', async () => { - const responsePromise = intercom.articles.list(); + const responsePromise = client.articles.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -932,7 +929,7 @@ describe('resource articles', () => { 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(intercom.articles.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.articles.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -940,12 +937,12 @@ describe('resource articles', () => { 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( - intercom.articles.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.articles.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('remove', async () => { - const responsePromise = intercom.articles.remove(123); + const responsePromise = client.articles.remove(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -957,7 +954,7 @@ describe('resource articles', () => { 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(intercom.articles.remove(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.articles.remove(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -965,12 +962,12 @@ describe('resource articles', () => { 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( - intercom.articles.remove(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.articles.remove(123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('search', async () => { - const responsePromise = intercom.articles.search(); + const responsePromise = client.articles.search(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -982,7 +979,7 @@ describe('resource articles', () => { 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(intercom.articles.search({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.articles.search({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -990,7 +987,7 @@ describe('resource articles', () => { 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( - intercom.articles.search( + client.articles.search( { help_center_id: 0, highlight: true, phrase: 'phrase', state: 'state', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/companies/companies.test.ts b/tests/api-resources/companies/companies.test.ts index b8e259df..4ba4a25a 100644 --- a/tests/api-resources/companies/companies.test.ts +++ b/tests/api-resources/companies/companies.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.companies.create(); + const responsePromise = client.companies.create(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource companies', () => { 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(intercom.companies.create({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.companies.create({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,7 +30,7 @@ describe('resource companies', () => { 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( - intercom.companies.create( + client.companies.create( { company_id: 'company_remote_id', custom_attributes: { paid_subscriber: 'string', monthly_spend: 'string', team_mates: 'string' }, @@ -49,7 +49,7 @@ describe('resource companies', () => { }); test('retrieve', async () => { - const responsePromise = intercom.companies.retrieve('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const responsePromise = client.companies.retrieve('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -62,16 +62,14 @@ describe('resource companies', () => { 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( - intercom.companies.retrieve('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { - path: '/_stainless_unknown_path', - }), + 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( - intercom.companies.retrieve( + client.companies.retrieve( '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -80,7 +78,7 @@ describe('resource companies', () => { }); test('update', async () => { - const responsePromise = intercom.companies.update('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const responsePromise = client.companies.update('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -93,14 +91,14 @@ describe('resource companies', () => { 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( - intercom.companies.update('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path' }), + 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( - intercom.companies.update( + client.companies.update( '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -109,7 +107,7 @@ describe('resource companies', () => { }); test('list', async () => { - const responsePromise = intercom.companies.list(); + const responsePromise = client.companies.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -121,7 +119,7 @@ describe('resource companies', () => { 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(intercom.companies.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.companies.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -129,7 +127,7 @@ describe('resource companies', () => { 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( - intercom.companies.list( + client.companies.list( { order: 'order', page: 0, per_page: 0, 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), @@ -137,7 +135,7 @@ describe('resource companies', () => { }); test('delete', async () => { - const responsePromise = intercom.companies.delete('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const responsePromise = client.companies.delete('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -150,14 +148,14 @@ describe('resource companies', () => { 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( - intercom.companies.delete('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path' }), + 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( - intercom.companies.delete( + client.companies.delete( '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -166,7 +164,7 @@ describe('resource companies', () => { }); test('retrieveList', async () => { - const responsePromise = intercom.companies.retrieveList(); + const responsePromise = client.companies.retrieveList(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -178,7 +176,7 @@ describe('resource companies', () => { 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(intercom.companies.retrieveList({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.companies.retrieveList({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -186,7 +184,7 @@ describe('resource companies', () => { 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( - intercom.companies.retrieveList( + client.companies.retrieveList( { company_id: 'company_id', name: 'name', @@ -202,7 +200,7 @@ describe('resource companies', () => { }); test('scroll', async () => { - const responsePromise = intercom.companies.scroll(); + const responsePromise = client.companies.scroll(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -214,7 +212,7 @@ describe('resource companies', () => { 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(intercom.companies.scroll({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.companies.scroll({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -222,7 +220,7 @@ describe('resource companies', () => { 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( - intercom.companies.scroll( + client.companies.scroll( { scroll_param: 'scroll_param', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/companies/contacts.test.ts b/tests/api-resources/companies/contacts.test.ts index d025797a..ddb61d76 100644 --- a/tests/api-resources/companies/contacts.test.ts +++ b/tests/api-resources/companies/contacts.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const responsePromise = client.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +23,7 @@ describe('resource contacts', () => { 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( - intercom.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { + client.companies.contacts.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Intercom.NotFoundError); @@ -32,7 +32,7 @@ describe('resource contacts', () => { 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( - intercom.companies.contacts.list( + client.companies.contacts.list( '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/companies/segments.test.ts b/tests/api-resources/companies/segments.test.ts index 91d5e9b5..611aeea7 100644 --- a/tests/api-resources/companies/segments.test.ts +++ b/tests/api-resources/companies/segments.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); + const responsePromise = client.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,7 +23,7 @@ describe('resource segments', () => { 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( - intercom.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { + client.companies.segments.list('5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Intercom.NotFoundError); @@ -32,7 +32,7 @@ describe('resource segments', () => { 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( - intercom.companies.segments.list( + client.companies.segments.list( '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/contacts/companies.test.ts b/tests/api-resources/contacts/companies.test.ts index 4f2254cc..6e986d1a 100644 --- a/tests/api-resources/contacts/companies.test.ts +++ b/tests/api-resources/contacts/companies.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.companies.create('contact_id', { + const responsePromise = client.contacts.companies.create('contact_id', { company_id: '6657add46abd0167d9419cd2', }); const rawResponse = await responsePromise.asResponse(); @@ -23,14 +23,14 @@ describe('resource companies', () => { }); test('create: required and optional params', async () => { - const response = await intercom.contacts.companies.create('contact_id', { + const response = await client.contacts.companies.create('contact_id', { company_id: '6657add46abd0167d9419cd2', 'Intercom-Version': '2.11', }); }); test('list', async () => { - const responsePromise = intercom.contacts.companies.list('contact_id'); + const responsePromise = client.contacts.companies.list('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -43,15 +43,15 @@ describe('resource companies', () => { 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( - intercom.contacts.companies.list('contact_id', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.companies.list( - 'contact_id', + client.contacts.companies.list( + '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), @@ -59,7 +59,7 @@ describe('resource companies', () => { }); test('delete', async () => { - const responsePromise = intercom.contacts.companies.delete( + const responsePromise = client.contacts.companies.delete( '58a430d35458202d41b1e65b', '58a430d35458202d41b1e65b', ); @@ -75,7 +75,7 @@ describe('resource companies', () => { 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( - intercom.contacts.companies.delete('58a430d35458202d41b1e65b', '58a430d35458202d41b1e65b', { + client.contacts.companies.delete('58a430d35458202d41b1e65b', '58a430d35458202d41b1e65b', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Intercom.NotFoundError); @@ -84,7 +84,7 @@ describe('resource companies', () => { 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( - intercom.contacts.companies.delete( + client.contacts.companies.delete( '58a430d35458202d41b1e65b', '58a430d35458202d41b1e65b', { 'Intercom-Version': '2.11' }, diff --git a/tests/api-resources/contacts/contacts.test.ts b/tests/api-resources/contacts/contacts.test.ts index 9a0a582f..382d5007 100644 --- a/tests/api-resources/contacts/contacts.test.ts +++ b/tests/api-resources/contacts/contacts.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.create({ body: {} }); + const responsePromise = client.contacts.create({ body: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,11 +21,11 @@ describe('resource contacts', () => { }); test('create: required and optional params', async () => { - const response = await intercom.contacts.create({ body: {}, 'Intercom-Version': '2.11' }); + const response = await client.contacts.create({ body: {}, 'Intercom-Version': '2.11' }); }); test('retrieve', async () => { - const responsePromise = intercom.contacts.retrieve('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.retrieve('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -38,14 +38,14 @@ describe('resource contacts', () => { 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( - intercom.contacts.retrieve('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.retrieve( + client.contacts.retrieve( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -54,7 +54,7 @@ describe('resource contacts', () => { }); test('update', async () => { - const responsePromise = intercom.contacts.update('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.update('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -67,14 +67,14 @@ describe('resource contacts', () => { 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( - intercom.contacts.update('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.update( + client.contacts.update( '63a07ddf05a32042dffac965', { avatar: 'https://www.example.com/avatar_image.jpg', @@ -96,7 +96,7 @@ describe('resource contacts', () => { }); test('list', async () => { - const responsePromise = intercom.contacts.list(); + const responsePromise = client.contacts.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -108,7 +108,7 @@ describe('resource contacts', () => { 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(intercom.contacts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.contacts.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -116,12 +116,12 @@ describe('resource contacts', () => { 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( - intercom.contacts.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.contacts.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('delete', async () => { - const responsePromise = intercom.contacts.delete('id'); + const responsePromise = client.contacts.delete('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -133,7 +133,7 @@ describe('resource contacts', () => { 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(intercom.contacts.delete('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.contacts.delete('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -141,12 +141,12 @@ describe('resource contacts', () => { 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( - intercom.contacts.delete('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.contacts.delete('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('archive', async () => { - const responsePromise = intercom.contacts.archive('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.archive('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -159,14 +159,14 @@ describe('resource contacts', () => { 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( - intercom.contacts.archive('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.archive( + client.contacts.archive( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -175,7 +175,7 @@ describe('resource contacts', () => { }); test('merge', async () => { - const responsePromise = intercom.contacts.merge(); + const responsePromise = client.contacts.merge(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -187,7 +187,7 @@ describe('resource contacts', () => { 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(intercom.contacts.merge({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.contacts.merge({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -195,7 +195,7 @@ describe('resource contacts', () => { 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( - intercom.contacts.merge( + client.contacts.merge( { from: '6657adf76abd0167d9419d1d', into: '6657adf76abd0167d9419d1e', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), @@ -203,7 +203,7 @@ describe('resource contacts', () => { }); test('search: only required params', async () => { - const responsePromise = intercom.contacts.search({ query: {} }); + const responsePromise = client.contacts.search({ query: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -214,7 +214,7 @@ describe('resource contacts', () => { }); test('search: required and optional params', async () => { - const response = await intercom.contacts.search({ + 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', @@ -222,7 +222,7 @@ describe('resource contacts', () => { }); test('unarchive', async () => { - const responsePromise = intercom.contacts.unarchive('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.unarchive('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -235,14 +235,14 @@ describe('resource contacts', () => { 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( - intercom.contacts.unarchive('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.unarchive( + client.contacts.unarchive( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/contacts/notes.test.ts b/tests/api-resources/contacts/notes.test.ts index 9cdac8c2..396c93bf 100644 --- a/tests/api-resources/contacts/notes.test.ts +++ b/tests/api-resources/contacts/notes.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.notes.create(0, { body: 'Hello' }); + const responsePromise = client.contacts.notes.create(0, { body: 'Hello' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource notes', () => { }); test('create: required and optional params', async () => { - const response = await intercom.contacts.notes.create(0, { + const response = await client.contacts.notes.create(0, { body: 'Hello', admin_id: 'admin_id', contact_id: '6657adde6abd0167d9419d00', @@ -30,7 +30,7 @@ describe('resource notes', () => { }); test('list', async () => { - const responsePromise = intercom.contacts.notes.list(0); + const responsePromise = client.contacts.notes.list(0); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -42,7 +42,7 @@ describe('resource notes', () => { 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(intercom.contacts.notes.list(0, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.contacts.notes.list(0, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -50,7 +50,7 @@ describe('resource notes', () => { 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( - intercom.contacts.notes.list(0, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index ac646a6c..a295ee8d 100644 --- a/tests/api-resources/contacts/segments.test.ts +++ b/tests/api-resources/contacts/segments.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.segments.list('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.segments.list('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource segments', () => { 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( - intercom.contacts.segments.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.segments.list( + client.contacts.segments.list( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/contacts/subscriptions.test.ts b/tests/api-resources/contacts/subscriptions.test.ts index 40e58e3d..32b84f7b 100644 --- a/tests/api-resources/contacts/subscriptions.test.ts +++ b/tests/api-resources/contacts/subscriptions.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.subscriptions.create('63a07ddf05a32042dffac965', { + const responsePromise = client.contacts.subscriptions.create('63a07ddf05a32042dffac965', { id: 'id', consent_type: 'opt_in', }); @@ -24,7 +24,7 @@ describe('resource subscriptions', () => { }); test('create: required and optional params', async () => { - const response = await intercom.contacts.subscriptions.create('63a07ddf05a32042dffac965', { + const response = await client.contacts.subscriptions.create('63a07ddf05a32042dffac965', { id: 'id', consent_type: 'opt_in', 'Intercom-Version': '2.11', @@ -32,7 +32,7 @@ describe('resource subscriptions', () => { }); test('list', async () => { - const responsePromise = intercom.contacts.subscriptions.list('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.subscriptions.list('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -45,14 +45,14 @@ describe('resource subscriptions', () => { 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( - intercom.contacts.subscriptions.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.subscriptions.list( + client.contacts.subscriptions.list( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -61,7 +61,7 @@ describe('resource subscriptions', () => { }); test('delete', async () => { - const responsePromise = intercom.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846'); + const responsePromise = client.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -74,7 +74,7 @@ describe('resource subscriptions', () => { 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( - intercom.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846', { + client.contacts.subscriptions.delete('63a07ddf05a32042dffac965', '37846', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Intercom.NotFoundError); @@ -83,7 +83,7 @@ describe('resource subscriptions', () => { 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( - intercom.contacts.subscriptions.delete( + client.contacts.subscriptions.delete( '63a07ddf05a32042dffac965', '37846', { 'Intercom-Version': '2.11' }, diff --git a/tests/api-resources/contacts/tags.test.ts b/tests/api-resources/contacts/tags.test.ts index 38afc850..ce7e2d51 100644 --- a/tests/api-resources/contacts/tags.test.ts +++ b/tests/api-resources/contacts/tags.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'id' }); + const responsePromise = client.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'id' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,14 +21,14 @@ describe('resource tags', () => { }); test('create: required and optional params', async () => { - const response = await intercom.contacts.tags.create('63a07ddf05a32042dffac965', { + const response = await client.contacts.tags.create('63a07ddf05a32042dffac965', { id: 'id', 'Intercom-Version': '2.11', }); }); test('list', async () => { - const responsePromise = intercom.contacts.tags.list('63a07ddf05a32042dffac965'); + const responsePromise = client.contacts.tags.list('63a07ddf05a32042dffac965'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -41,14 +41,14 @@ describe('resource tags', () => { 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( - intercom.contacts.tags.list('63a07ddf05a32042dffac965', { path: '/_stainless_unknown_path' }), + 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( - intercom.contacts.tags.list( + client.contacts.tags.list( '63a07ddf05a32042dffac965', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -57,7 +57,7 @@ describe('resource tags', () => { }); test('delete', async () => { - const responsePromise = intercom.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907'); + const responsePromise = client.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -70,7 +70,7 @@ describe('resource tags', () => { 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( - intercom.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907', { + client.contacts.tags.delete('63a07ddf05a32042dffac965', '7522907', { path: '/_stainless_unknown_path', }), ).rejects.toThrow(Intercom.NotFoundError); @@ -79,7 +79,7 @@ describe('resource tags', () => { 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( - intercom.contacts.tags.delete( + client.contacts.tags.delete( '63a07ddf05a32042dffac965', '7522907', { 'Intercom-Version': '2.11' }, diff --git a/tests/api-resources/conversations/conversations.test.ts b/tests/api-resources/conversations/conversations.test.ts index 987469b9..5668bf42 100644 --- a/tests/api-resources/conversations/conversations.test.ts +++ b/tests/api-resources/conversations/conversations.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.create({ + const responsePromise = client.conversations.create({ body: 'Hello there', from: { type: 'user', id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }, }); @@ -24,7 +24,7 @@ describe('resource conversations', () => { }); test('create: required and optional params', async () => { - const response = await intercom.conversations.create({ + const response = await client.conversations.create({ body: 'Hello there', from: { type: 'user', id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }, 'Intercom-Version': '2.11', @@ -32,7 +32,7 @@ describe('resource conversations', () => { }); test('retrieve', async () => { - const responsePromise = intercom.conversations.retrieve(123); + const responsePromise = client.conversations.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -44,7 +44,7 @@ describe('resource conversations', () => { 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(intercom.conversations.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.conversations.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -52,7 +52,7 @@ describe('resource conversations', () => { 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( - intercom.conversations.retrieve( + client.conversations.retrieve( 123, { display_as: 'display_as', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -61,7 +61,7 @@ describe('resource conversations', () => { }); test('update', async () => { - const responsePromise = intercom.conversations.update(123); + const responsePromise = client.conversations.update(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -73,7 +73,7 @@ describe('resource conversations', () => { 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(intercom.conversations.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.conversations.update(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -81,7 +81,7 @@ describe('resource conversations', () => { 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( - intercom.conversations.update( + client.conversations.update( 123, { display_as: 'display_as', @@ -95,7 +95,7 @@ describe('resource conversations', () => { }); test('list', async () => { - const responsePromise = intercom.conversations.list(); + const responsePromise = client.conversations.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -107,7 +107,7 @@ describe('resource conversations', () => { 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(intercom.conversations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.conversations.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -115,7 +115,7 @@ describe('resource conversations', () => { 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( - intercom.conversations.list( + client.conversations.list( { per_page: 0, starting_after: 'starting_after', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), @@ -123,7 +123,7 @@ describe('resource conversations', () => { }); test('convert: only required params', async () => { - const responsePromise = intercom.conversations.convert(123, { ticket_type_id: '120' }); + const responsePromise = client.conversations.convert(123, { ticket_type_id: '120' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -134,7 +134,7 @@ describe('resource conversations', () => { }); test('convert: required and optional params', async () => { - const response = await intercom.conversations.convert(123, { + 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', @@ -142,7 +142,7 @@ describe('resource conversations', () => { }); test('redact: only required params', async () => { - const responsePromise = intercom.conversations.redact({ + const responsePromise = client.conversations.redact({ conversation_id: '19894788788', conversation_part_id: '19381789428', type: 'conversation_part', @@ -157,7 +157,7 @@ describe('resource conversations', () => { }); test('redact: required and optional params', async () => { - const response = await intercom.conversations.redact({ + const response = await client.conversations.redact({ conversation_id: '19894788788', conversation_part_id: '19381789428', type: 'conversation_part', @@ -166,7 +166,7 @@ describe('resource conversations', () => { }); test('search: only required params', async () => { - const responsePromise = intercom.conversations.search({ query: {} }); + const responsePromise = client.conversations.search({ query: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -177,7 +177,7 @@ describe('resource conversations', () => { }); test('search: required and optional params', async () => { - const response = await intercom.conversations.search({ + 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 index 3afa6091..0fe51393 100644 --- a/tests/api-resources/conversations/customers.test.ts +++ b/tests/api-resources/conversations/customers.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.customers.create('123'); + const responsePromise = client.conversations.customers.create('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource customers', () => { 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( - intercom.conversations.customers.create('123', { path: '/_stainless_unknown_path' }), + 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( - intercom.conversations.customers.create( + client.conversations.customers.create( '123', { admin_id: 'admin_id', @@ -46,7 +46,7 @@ describe('resource customers', () => { }); test('delete: only required params', async () => { - const responsePromise = intercom.conversations.customers.delete('123', '123', { admin_id: 'admin_id' }); + 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; @@ -57,7 +57,7 @@ describe('resource customers', () => { }); test('delete: required and optional params', async () => { - const response = await intercom.conversations.customers.delete('123', '123', { + 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 index 910b2e7f..e6a93f15 100644 --- a/tests/api-resources/conversations/parts.test.ts +++ b/tests/api-resources/conversations/parts.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.parts.create('123', { + const responsePromise = client.conversations.parts.create('123', { admin_id: '12345', message_type: 'close', type: 'admin', @@ -25,7 +25,7 @@ describe('resource parts', () => { }); test('create: required and optional params', async () => { - const response = await intercom.conversations.parts.create('123', { + const response = await client.conversations.parts.create('123', { admin_id: '12345', message_type: 'close', type: 'admin', diff --git a/tests/api-resources/conversations/reply.test.ts b/tests/api-resources/conversations/reply.test.ts index 146a4612..70f7c637 100644 --- a/tests/api-resources/conversations/reply.test.ts +++ b/tests/api-resources/conversations/reply.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.reply.create('123 or "last"', { + const responsePromise = client.conversations.reply.create('123 or "last"', { body: 'body', message_type: 'comment', type: 'user', @@ -25,7 +25,7 @@ describe('resource reply', () => { }); test('create: required and optional params', async () => { - const response = await intercom.conversations.reply.create('123 or "last"', { + const response = await client.conversations.reply.create('123 or "last"', { body: 'body', message_type: 'comment', type: 'user', diff --git a/tests/api-resources/conversations/run-assignment-rules.test.ts b/tests/api-resources/conversations/run-assignment-rules.test.ts index c9efec1a..e4cdfecb 100644 --- a/tests/api-resources/conversations/run-assignment-rules.test.ts +++ b/tests/api-resources/conversations/run-assignment-rules.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.runAssignmentRules.create('123'); + const responsePromise = client.conversations.runAssignmentRules.create('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource runAssignmentRules', () => { 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( - intercom.conversations.runAssignmentRules.create('123', { path: '/_stainless_unknown_path' }), + 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( - intercom.conversations.runAssignmentRules.create( + client.conversations.runAssignmentRules.create( '123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/conversations/tags.test.ts b/tests/api-resources/conversations/tags.test.ts index 255d7774..6b462288 100644 --- a/tests/api-resources/conversations/tags.test.ts +++ b/tests/api-resources/conversations/tags.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.conversations.tags.create('64619700005694', { + const responsePromise = client.conversations.tags.create('64619700005694', { id: 'id', admin_id: 'admin_id', }); @@ -24,7 +24,7 @@ describe('resource tags', () => { }); test('create: required and optional params', async () => { - const response = await intercom.conversations.tags.create('64619700005694', { + const response = await client.conversations.tags.create('64619700005694', { id: 'id', admin_id: 'admin_id', 'Intercom-Version': '2.11', @@ -32,7 +32,7 @@ describe('resource tags', () => { }); test('delete: only required params', async () => { - const responsePromise = intercom.conversations.tags.delete('64619700005694', '7522907', { + const responsePromise = client.conversations.tags.delete('64619700005694', '7522907', { admin_id: 'admin_id', }); const rawResponse = await responsePromise.asResponse(); @@ -45,7 +45,7 @@ describe('resource tags', () => { }); test('delete: required and optional params', async () => { - const response = await intercom.conversations.tags.delete('64619700005694', '7522907', { + 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 index f037eef3..5cba46a5 100644 --- a/tests/api-resources/data-attributes.test.ts +++ b/tests/api-resources/data-attributes.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.dataAttributes.create({ + const responsePromise = client.dataAttributes.create({ data_type: 'string', model: 'company', name: 'Mithril Shirt', @@ -25,7 +25,7 @@ describe('resource dataAttributes', () => { }); test('create: required and optional params', async () => { - const response = await intercom.dataAttributes.create({ + const response = await client.dataAttributes.create({ data_type: 'string', model: 'company', name: 'Mithril Shirt', @@ -37,7 +37,7 @@ describe('resource dataAttributes', () => { }); test('update', async () => { - const responsePromise = intercom.dataAttributes.update(1); + const responsePromise = client.dataAttributes.update(1); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -49,7 +49,7 @@ describe('resource dataAttributes', () => { 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(intercom.dataAttributes.update(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.dataAttributes.update(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -57,7 +57,7 @@ describe('resource dataAttributes', () => { 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( - intercom.dataAttributes.update( + client.dataAttributes.update( 1, { archived: false, @@ -72,7 +72,7 @@ describe('resource dataAttributes', () => { }); test('list', async () => { - const responsePromise = intercom.dataAttributes.list(); + const responsePromise = client.dataAttributes.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -84,7 +84,7 @@ describe('resource dataAttributes', () => { 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(intercom.dataAttributes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.dataAttributes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -92,7 +92,7 @@ describe('resource dataAttributes', () => { 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( - intercom.dataAttributes.list( + client.dataAttributes.list( { include_archived: true, model: 'contact', 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/data-events.test.ts b/tests/api-resources/data-events.test.ts index b3a5cb01..2c347bce 100644 --- a/tests/api-resources/data-events.test.ts +++ b/tests/api-resources/data-events.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.dataEvents.create({ body: {} }); + const responsePromise = client.dataEvents.create({ body: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,11 +21,11 @@ describe('resource dataEvents', () => { }); test('create: required and optional params', async () => { - const response = await intercom.dataEvents.create({ body: {}, 'Intercom-Version': '2.11' }); + const response = await client.dataEvents.create({ body: {}, 'Intercom-Version': '2.11' }); }); test('list: only required params', async () => { - const responsePromise = intercom.dataEvents.list({ filter: { user_id: 'user_id' }, type: 'type' }); + 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; @@ -36,7 +36,7 @@ describe('resource dataEvents', () => { }); test('list: required and optional params', async () => { - const response = await intercom.dataEvents.list({ + const response = await client.dataEvents.list({ filter: { user_id: 'user_id' }, type: 'type', summary: true, @@ -45,7 +45,7 @@ describe('resource dataEvents', () => { }); test('summaries', async () => { - const responsePromise = intercom.dataEvents.summaries(); + const responsePromise = client.dataEvents.summaries(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -57,7 +57,7 @@ describe('resource dataEvents', () => { 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(intercom.dataEvents.summaries({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.dataEvents.summaries({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -65,7 +65,7 @@ describe('resource dataEvents', () => { 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( - intercom.dataEvents.summaries( + client.dataEvents.summaries( { event_summaries: { event_name: 'invited-friend', count: 1, first: 1671028894, last: 1671028894 }, user_id: '314159', diff --git a/tests/api-resources/data-exports.test.ts b/tests/api-resources/data-exports.test.ts index 6e525971..0c126881 100644 --- a/tests/api-resources/data-exports.test.ts +++ b/tests/api-resources/data-exports.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.dataExports.contentData({ + const responsePromise = client.dataExports.contentData({ created_at_after: 1717004390, created_at_before: 1717022390, }); @@ -24,7 +24,7 @@ describe('resource dataExports', () => { }); test('contentData: required and optional params', async () => { - const response = await intercom.dataExports.contentData({ + 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 index 0b5b087b..bab30d1a 100644 --- a/tests/api-resources/download/content/data.test.ts +++ b/tests/api-resources/download/content/data.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.download.content.data.retrieve('job_identifier'); + const responsePromise = client.download.content.data.retrieve('job_identifier'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource data', () => { 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( - intercom.download.content.data.retrieve('job_identifier', { path: '/_stainless_unknown_path' }), + 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( - intercom.download.content.data.retrieve( + client.download.content.data.retrieve( 'job_identifier', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/export/content/data.test.ts b/tests/api-resources/export/content/data.test.ts index 738f9371..2c8fbedd 100644 --- a/tests/api-resources/export/content/data.test.ts +++ b/tests/api-resources/export/content/data.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.export.content.data.retrieve('job_identifier'); + const responsePromise = client.export.content.data.retrieve('job_identifier'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource data', () => { 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( - intercom.export.content.data.retrieve('job_identifier', { path: '/_stainless_unknown_path' }), + 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( - intercom.export.content.data.retrieve( + client.export.content.data.retrieve( 'job_identifier', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/export/export.test.ts b/tests/api-resources/export/export.test.ts index 6da63c2f..1d684164 100644 --- a/tests/api-resources/export/export.test.ts +++ b/tests/api-resources/export/export.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.export.cancel('job_identifier'); + const responsePromise = client.export.cancel('job_identifier'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource export', () => { 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( - intercom.export.cancel('job_identifier', { path: '/_stainless_unknown_path' }), + 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( - intercom.export.cancel( + client.export.cancel( 'job_identifier', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/help-center/collections.test.ts b/tests/api-resources/help-center/collections.test.ts index e44d4ed5..b481ceb5 100644 --- a/tests/api-resources/help-center/collections.test.ts +++ b/tests/api-resources/help-center/collections.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.helpCenter.collections.create({ name: 'Thanks for everything' }); + const responsePromise = client.helpCenter.collections.create({ name: 'Thanks for everything' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource collections', () => { }); test('create: required and optional params', async () => { - const response = await intercom.helpCenter.collections.create({ + const response = await client.helpCenter.collections.create({ name: 'Thanks for everything', description: 'English description', help_center_id: 0, @@ -71,7 +71,7 @@ describe('resource collections', () => { }); test('retrieve', async () => { - const responsePromise = intercom.helpCenter.collections.retrieve(123); + const responsePromise = client.helpCenter.collections.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -84,14 +84,14 @@ describe('resource collections', () => { 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( - intercom.helpCenter.collections.retrieve(123, { path: '/_stainless_unknown_path' }), + 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( - intercom.helpCenter.collections.retrieve( + client.helpCenter.collections.retrieve( 123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -100,7 +100,7 @@ describe('resource collections', () => { }); test('update', async () => { - const responsePromise = intercom.helpCenter.collections.update(123); + const responsePromise = client.helpCenter.collections.update(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -113,14 +113,14 @@ describe('resource collections', () => { 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( - intercom.helpCenter.collections.update(123, { path: '/_stainless_unknown_path' }), + 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( - intercom.helpCenter.collections.update( + client.helpCenter.collections.update( 123, { description: 'English description', @@ -186,7 +186,7 @@ describe('resource collections', () => { }); test('list', async () => { - const responsePromise = intercom.helpCenter.collections.list(); + const responsePromise = client.helpCenter.collections.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -198,7 +198,7 @@ describe('resource collections', () => { 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(intercom.helpCenter.collections.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.helpCenter.collections.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -206,7 +206,7 @@ describe('resource collections', () => { 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( - intercom.helpCenter.collections.list( + client.helpCenter.collections.list( { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), @@ -214,7 +214,7 @@ describe('resource collections', () => { }); test('delete', async () => { - const responsePromise = intercom.helpCenter.collections.delete(123); + const responsePromise = client.helpCenter.collections.delete(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -227,14 +227,14 @@ describe('resource collections', () => { 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( - intercom.helpCenter.collections.delete(123, { path: '/_stainless_unknown_path' }), + 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( - intercom.helpCenter.collections.delete( + client.helpCenter.collections.delete( 123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/help-center/help-centers.test.ts b/tests/api-resources/help-center/help-centers.test.ts index 7abfcf01..9f3abe74 100644 --- a/tests/api-resources/help-center/help-centers.test.ts +++ b/tests/api-resources/help-center/help-centers.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.helpCenter.helpCenters.retrieve(123); + const responsePromise = client.helpCenter.helpCenters.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource helpCenters', () => { 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( - intercom.helpCenter.helpCenters.retrieve(123, { path: '/_stainless_unknown_path' }), + 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( - intercom.helpCenter.helpCenters.retrieve( + client.helpCenter.helpCenters.retrieve( 123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -39,7 +39,7 @@ describe('resource helpCenters', () => { }); test('list', async () => { - const responsePromise = intercom.helpCenter.helpCenters.list(); + const responsePromise = client.helpCenter.helpCenters.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -51,7 +51,7 @@ describe('resource helpCenters', () => { 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(intercom.helpCenter.helpCenters.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.helpCenter.helpCenters.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -59,7 +59,7 @@ describe('resource helpCenters', () => { 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( - intercom.helpCenter.helpCenters.list( + client.helpCenter.helpCenters.list( { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/me.test.ts b/tests/api-resources/me.test.ts index 6361fb3c..d4ad2666 100644 --- a/tests/api-resources/me.test.ts +++ b/tests/api-resources/me.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.me.retrieve(); + const responsePromise = client.me.retrieve(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource me', () => { 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(intercom.me.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.me.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,7 +30,7 @@ describe('resource me', () => { 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( - intercom.me.retrieve({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index af190ca1..afb89e9b 100644 --- a/tests/api-resources/messages.test.ts +++ b/tests/api-resources/messages.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.messages.create({ body: {} }); + const responsePromise = client.messages.create({ body: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,6 +21,6 @@ describe('resource messages', () => { }); test('create: required and optional params', async () => { - const response = await intercom.messages.create({ body: {}, 'Intercom-Version': '2.11' }); + 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 index f0275ce5..f7275466 100644 --- a/tests/api-resources/news/news-items.test.ts +++ b/tests/api-resources/news/news-items.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.news.newsItems.create({ + const responsePromise = client.news.newsItems.create({ sender_id: 991268690, title: 'Halloween is here!', }); @@ -24,7 +24,7 @@ describe('resource newsItems', () => { }); test('create: required and optional params', async () => { - const response = await intercom.news.newsItems.create({ + const response = await client.news.newsItems.create({ sender_id: 991268690, title: 'Halloween is here!', body: '

New costumes in store for this spooky season

', @@ -38,7 +38,7 @@ describe('resource newsItems', () => { }); test('retrieve', async () => { - const responsePromise = intercom.news.newsItems.retrieve(123); + const responsePromise = client.news.newsItems.retrieve(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -50,7 +50,7 @@ describe('resource newsItems', () => { 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(intercom.news.newsItems.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.news.newsItems.retrieve(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -58,7 +58,7 @@ describe('resource newsItems', () => { 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( - intercom.news.newsItems.retrieve( + client.news.newsItems.retrieve( 123, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -67,7 +67,7 @@ describe('resource newsItems', () => { }); test('update: only required params', async () => { - const responsePromise = intercom.news.newsItems.update(123, { + const responsePromise = client.news.newsItems.update(123, { sender_id: 991268701, title: 'Christmas is here!', }); @@ -81,7 +81,7 @@ describe('resource newsItems', () => { }); test('update: required and optional params', async () => { - const response = await intercom.news.newsItems.update(123, { + const response = await client.news.newsItems.update(123, { sender_id: 991268701, title: 'Christmas is here!', body: '

New gifts in store for the jolly season

', @@ -99,7 +99,7 @@ describe('resource newsItems', () => { }); test('list', async () => { - const responsePromise = intercom.news.newsItems.list(); + const responsePromise = client.news.newsItems.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -111,7 +111,7 @@ describe('resource newsItems', () => { 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(intercom.news.newsItems.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.news.newsItems.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -119,12 +119,12 @@ describe('resource newsItems', () => { 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( - intercom.news.newsItems.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.news.newsItems.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('delete', async () => { - const responsePromise = intercom.news.newsItems.delete(123); + const responsePromise = client.news.newsItems.delete(123); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -136,7 +136,7 @@ describe('resource newsItems', () => { 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(intercom.news.newsItems.delete(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.news.newsItems.delete(123, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -144,11 +144,7 @@ describe('resource newsItems', () => { 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( - intercom.news.newsItems.delete( - 123, - { 'Intercom-Version': '2.11' }, - { path: '/_stainless_unknown_path' }, - ), + 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 index 827855f8..91ec34c8 100644 --- a/tests/api-resources/news/newsfeeds/items.test.ts +++ b/tests/api-resources/news/newsfeeds/items.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.news.newsfeeds.items.list('123'); + const responsePromise = client.news.newsfeeds.items.list('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -23,14 +23,14 @@ describe('resource items', () => { 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( - intercom.news.newsfeeds.items.list('123', { path: '/_stainless_unknown_path' }), + 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( - intercom.news.newsfeeds.items.list( + client.news.newsfeeds.items.list( '123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, diff --git a/tests/api-resources/news/newsfeeds/newsfeeds.test.ts b/tests/api-resources/news/newsfeeds/newsfeeds.test.ts index 3476f82e..b5d0c844 100644 --- a/tests/api-resources/news/newsfeeds/newsfeeds.test.ts +++ b/tests/api-resources/news/newsfeeds/newsfeeds.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.news.newsfeeds.retrieve('123'); + const responsePromise = client.news.newsfeeds.retrieve('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,15 +22,15 @@ describe('resource newsfeeds', () => { 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( - intercom.news.newsfeeds.retrieve('123', { path: '/_stainless_unknown_path' }), - ).rejects.toThrow(Intercom.NotFoundError); + 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( - intercom.news.newsfeeds.retrieve( + client.news.newsfeeds.retrieve( '123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, @@ -39,7 +39,7 @@ describe('resource newsfeeds', () => { }); test('list', async () => { - const responsePromise = intercom.news.newsfeeds.list(); + const responsePromise = client.news.newsfeeds.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -51,7 +51,7 @@ describe('resource newsfeeds', () => { 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(intercom.news.newsfeeds.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.news.newsfeeds.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -59,7 +59,7 @@ describe('resource newsfeeds', () => { 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( - intercom.news.newsfeeds.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index 5e6c0456..52250332 100644 --- a/tests/api-resources/notes.test.ts +++ b/tests/api-resources/notes.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.notes.retrieve(1); + const responsePromise = client.notes.retrieve(1); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource notes', () => { 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(intercom.notes.retrieve(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.notes.retrieve(1, { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,7 +30,7 @@ describe('resource notes', () => { 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( - intercom.notes.retrieve(1, { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index 04f6e6a6..90fb9d6c 100644 --- a/tests/api-resources/phone-call-redirects.test.ts +++ b/tests/api-resources/phone-call-redirects.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.phoneCallRedirects.create({ phone: '+353832345678' }); + const responsePromise = client.phoneCallRedirects.create({ phone: '+353832345678' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource phoneCallRedirects', () => { }); test('create: required and optional params', async () => { - const response = await intercom.phoneCallRedirects.create({ + 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 index 9ef3ff6c..510a4788 100644 --- a/tests/api-resources/segments.test.ts +++ b/tests/api-resources/segments.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.segments.retrieve('123'); + const responsePromise = client.segments.retrieve('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource segments', () => { 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(intercom.segments.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.segments.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,12 +30,12 @@ describe('resource segments', () => { 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( - intercom.segments.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.segments.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('list', async () => { - const responsePromise = intercom.segments.list(); + const responsePromise = client.segments.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -47,7 +47,7 @@ describe('resource segments', () => { 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(intercom.segments.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.segments.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -55,7 +55,7 @@ describe('resource segments', () => { 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( - intercom.segments.list( + client.segments.list( { include_count: true, 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }, ), diff --git a/tests/api-resources/subscription-types.test.ts b/tests/api-resources/subscription-types.test.ts index 9b60a25b..8cf81d01 100644 --- a/tests/api-resources/subscription-types.test.ts +++ b/tests/api-resources/subscription-types.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.subscriptionTypes.list(); + const responsePromise = client.subscriptionTypes.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource subscriptionTypes', () => { 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(intercom.subscriptionTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.subscriptionTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,7 +30,7 @@ describe('resource subscriptionTypes', () => { 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( - intercom.subscriptionTypes.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index 2c97ea0b..f057f08f 100644 --- a/tests/api-resources/tags.test.ts +++ b/tests/api-resources/tags.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.tags.retrieve('123'); + const responsePromise = client.tags.retrieve('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource tags', () => { 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(intercom.tags.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.tags.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,12 +30,12 @@ describe('resource tags', () => { 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( - intercom.tags.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.tags.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('list', async () => { - const responsePromise = intercom.tags.list(); + const responsePromise = client.tags.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -47,7 +47,7 @@ describe('resource tags', () => { 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(intercom.tags.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.tags.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -55,12 +55,12 @@ describe('resource tags', () => { 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( - intercom.tags.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.tags.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('delete', async () => { - const responsePromise = intercom.tags.delete('123'); + const responsePromise = client.tags.delete('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -72,7 +72,7 @@ describe('resource tags', () => { 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(intercom.tags.delete('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.tags.delete('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -80,12 +80,12 @@ describe('resource tags', () => { 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( - intercom.tags.delete('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.tags.delete('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('createOrUpdate: only required params', async () => { - const responsePromise = intercom.tags.createOrUpdate({ name: 'Independent' }); + const responsePromise = client.tags.createOrUpdate({ name: 'Independent' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -96,7 +96,7 @@ describe('resource tags', () => { }); test('createOrUpdate: required and optional params', async () => { - const response = await intercom.tags.createOrUpdate({ + 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 index f75fb9a4..93aef350 100644 --- a/tests/api-resources/teams.test.ts +++ b/tests/api-resources/teams.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.teams.retrieve('123'); + const responsePromise = client.teams.retrieve('123'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,7 +22,7 @@ describe('resource teams', () => { 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(intercom.teams.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.teams.retrieve('123', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -30,12 +30,12 @@ describe('resource teams', () => { 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( - intercom.teams.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + client.teams.retrieve('123', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('list', async () => { - const responsePromise = intercom.teams.list(); + const responsePromise = client.teams.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -47,7 +47,7 @@ describe('resource teams', () => { 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(intercom.teams.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.teams.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -55,7 +55,7 @@ describe('resource teams', () => { 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( - intercom.teams.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index e6e52c08..3f4693db 100644 --- a/tests/api-resources/ticket-types/attributes.test.ts +++ b/tests/api-resources/ticket-types/attributes.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.ticketTypes.attributes.create('ticket_type_id', { + const responsePromise = client.ticketTypes.attributes.create('ticket_type_id', { data_type: 'string', description: 'Attribute Description', name: 'Attribute Title', @@ -25,7 +25,7 @@ describe('resource attributes', () => { }); test('create: required and optional params', async () => { - const response = await intercom.ticketTypes.attributes.create('ticket_type_id', { + const response = await client.ticketTypes.attributes.create('ticket_type_id', { data_type: 'string', description: 'Attribute Description', name: 'Attribute Title', @@ -41,7 +41,7 @@ describe('resource attributes', () => { }); test('update', async () => { - const responsePromise = intercom.ticketTypes.attributes.update('ticket_type_id', 'id'); + const responsePromise = client.ticketTypes.attributes.update('ticket_type_id', 'id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -54,14 +54,14 @@ describe('resource attributes', () => { 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( - intercom.ticketTypes.attributes.update('ticket_type_id', 'id', { path: '/_stainless_unknown_path' }), + 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( - intercom.ticketTypes.attributes.update( + client.ticketTypes.attributes.update( 'ticket_type_id', 'id', { diff --git a/tests/api-resources/ticket-types/ticket-types.test.ts b/tests/api-resources/ticket-types/ticket-types.test.ts index df5bfdd3..b682a9c9 100644 --- a/tests/api-resources/ticket-types/ticket-types.test.ts +++ b/tests/api-resources/ticket-types/ticket-types.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.ticketTypes.create({ name: 'Customer Issue' }); + const responsePromise = client.ticketTypes.create({ name: 'Customer Issue' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,7 +21,7 @@ describe('resource ticketTypes', () => { }); test('create: required and optional params', async () => { - const response = await intercom.ticketTypes.create({ + const response = await client.ticketTypes.create({ name: 'Customer Issue', category: 'Customer', description: 'Customer Report Template', @@ -32,7 +32,7 @@ describe('resource ticketTypes', () => { }); test('retrieve', async () => { - const responsePromise = intercom.ticketTypes.retrieve('id'); + const responsePromise = client.ticketTypes.retrieve('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -44,7 +44,7 @@ describe('resource ticketTypes', () => { 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(intercom.ticketTypes.retrieve('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.ticketTypes.retrieve('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -52,16 +52,12 @@ describe('resource ticketTypes', () => { 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( - intercom.ticketTypes.retrieve( - 'id', - { 'Intercom-Version': '2.11' }, - { path: '/_stainless_unknown_path' }, - ), + client.ticketTypes.retrieve('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('update', async () => { - const responsePromise = intercom.ticketTypes.update('id'); + const responsePromise = client.ticketTypes.update('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -73,7 +69,7 @@ describe('resource ticketTypes', () => { 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(intercom.ticketTypes.update('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.ticketTypes.update('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -81,7 +77,7 @@ describe('resource ticketTypes', () => { 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( - intercom.ticketTypes.update( + client.ticketTypes.update( 'id', { archived: false, @@ -98,7 +94,7 @@ describe('resource ticketTypes', () => { }); test('list', async () => { - const responsePromise = intercom.ticketTypes.list(); + const responsePromise = client.ticketTypes.list(); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -110,7 +106,7 @@ describe('resource ticketTypes', () => { 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(intercom.ticketTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.ticketTypes.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -118,7 +114,7 @@ describe('resource ticketTypes', () => { 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( - intercom.ticketTypes.list({ 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), + 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 index 1cb6910b..0cae5b55 100644 --- a/tests/api-resources/tickets/tags.test.ts +++ b/tests/api-resources/tickets/tags.test.ts @@ -3,17 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.tickets.tags.create('64619700005694', { - id: 'id', - admin_id: 'admin_id', - }); + 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; @@ -24,7 +21,7 @@ describe('resource tags', () => { }); test('create: required and optional params', async () => { - const response = await intercom.tickets.tags.create('64619700005694', { + const response = await client.tickets.tags.create('64619700005694', { id: 'id', admin_id: 'admin_id', 'Intercom-Version': '2.11', @@ -32,9 +29,7 @@ describe('resource tags', () => { }); test('remove: only required params', async () => { - const responsePromise = intercom.tickets.tags.remove('64619700005694', '7522907', { - admin_id: 'admin_id', - }); + 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; @@ -45,7 +40,7 @@ describe('resource tags', () => { }); test('remove: required and optional params', async () => { - const response = await intercom.tickets.tags.remove('64619700005694', '7522907', { + 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 index 9b716fad..f71f5dd5 100644 --- a/tests/api-resources/tickets/tickets.test.ts +++ b/tests/api-resources/tickets/tickets.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.tickets.create({ + const responsePromise = client.tickets.create({ contacts: [{ id: '6657af026abd0167d9419def' }], ticket_type_id: 'ticket_type_id', }); @@ -24,7 +24,7 @@ describe('resource tickets', () => { }); test('create: required and optional params', async () => { - const response = await intercom.tickets.create({ + const response = await client.tickets.create({ contacts: [{ id: '6657af026abd0167d9419def' }], ticket_type_id: 'ticket_type_id', company_id: '1234', @@ -35,7 +35,7 @@ describe('resource tickets', () => { }); test('reply: only required params', async () => { - const responsePromise = intercom.tickets.reply('123', { + const responsePromise = client.tickets.reply('123', { body: 'body', message_type: 'comment', type: 'user', @@ -50,7 +50,7 @@ describe('resource tickets', () => { }); test('reply: required and optional params', async () => { - const response = await intercom.tickets.reply('123', { + const response = await client.tickets.reply('123', { body: 'body', message_type: 'comment', type: 'user', @@ -61,7 +61,7 @@ describe('resource tickets', () => { }); test('retrieveById', async () => { - const responsePromise = intercom.tickets.retrieveById('id'); + const responsePromise = client.tickets.retrieveById('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -73,7 +73,7 @@ describe('resource tickets', () => { 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(intercom.tickets.retrieveById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.tickets.retrieveById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -81,16 +81,12 @@ describe('resource tickets', () => { 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( - intercom.tickets.retrieveById( - 'id', - { 'Intercom-Version': '2.11' }, - { path: '/_stainless_unknown_path' }, - ), + client.tickets.retrieveById('id', { 'Intercom-Version': '2.11' }, { path: '/_stainless_unknown_path' }), ).rejects.toThrow(Intercom.NotFoundError); }); test('search: only required params', async () => { - const responsePromise = intercom.tickets.search({ query: {} }); + const responsePromise = client.tickets.search({ query: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -101,7 +97,7 @@ describe('resource tickets', () => { }); test('search: required and optional params', async () => { - const response = await intercom.tickets.search({ + 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', @@ -109,7 +105,7 @@ describe('resource tickets', () => { }); test('updateById', async () => { - const responsePromise = intercom.tickets.updateById('id'); + const responsePromise = client.tickets.updateById('id'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -121,7 +117,7 @@ describe('resource tickets', () => { 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(intercom.tickets.updateById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( + await expect(client.tickets.updateById('id', { path: '/_stainless_unknown_path' })).rejects.toThrow( Intercom.NotFoundError, ); }); @@ -129,7 +125,7 @@ describe('resource tickets', () => { 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( - intercom.tickets.updateById( + client.tickets.updateById( 'id', { assignment: { admin_id: '991268839', assignee_id: '991268841' }, diff --git a/tests/api-resources/visitors.test.ts b/tests/api-resources/visitors.test.ts index 0c57fa61..b3f217b3 100644 --- a/tests/api-resources/visitors.test.ts +++ b/tests/api-resources/visitors.test.ts @@ -3,14 +3,14 @@ import Intercom from 'intercom-client'; import { Response } from 'node-fetch'; -const intercom = new Intercom({ +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 = intercom.visitors.retrieve({ user_id: 'user_id' }); + const responsePromise = client.visitors.retrieve({ user_id: 'user_id' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -21,11 +21,11 @@ describe('resource visitors', () => { }); test('retrieve: required and optional params', async () => { - const response = await intercom.visitors.retrieve({ user_id: 'user_id', 'Intercom-Version': '2.11' }); + const response = await client.visitors.retrieve({ user_id: 'user_id', 'Intercom-Version': '2.11' }); }); test('update: only required params', async () => { - const responsePromise = intercom.visitors.update({ body: {} }); + const responsePromise = client.visitors.update({ body: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -36,11 +36,11 @@ describe('resource visitors', () => { }); test('update: required and optional params', async () => { - const response = await intercom.visitors.update({ body: {}, 'Intercom-Version': '2.11' }); + const response = await client.visitors.update({ body: {}, 'Intercom-Version': '2.11' }); }); test('convert: only required params', async () => { - const responsePromise = intercom.visitors.convert({ type: 'user', user: {}, visitor: {} }); + const responsePromise = client.visitors.convert({ type: 'user', user: {}, visitor: {} }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -51,7 +51,7 @@ describe('resource visitors', () => { }); test('convert: required and optional params', async () => { - const response = await intercom.visitors.convert({ + const response = await client.visitors.convert({ type: 'user', user: { id: '8a88a590-e1c3-41e2-a502-e0649dbf721c', diff --git a/yarn.lock b/yarn.lock index 648fb3cc..91bd58e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3518,11 +3518,6 @@ web-streams-polyfill@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== -web-streams-polyfill@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" - integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"